"the last change" for ranges
kjkilpi at gmail.com
Wed May 20 13:37:34 PDT 2009
On Wed, 20 May 2009 21:02:02 +0300, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Robert Jacques wrote:
>> Bicycle shed: Well, since output ranges use 'put', how about 'get' for
>> input ranges?
> Nice color :o). In fact, "put" is a poor choice because it doesn't
> reflect advancement. Probably putNext and getNext are better.
(Just thinking aloud... :) ) I have been using get() + set() and read() +
read() and write() advance to the next item; get() + set() do not.
Actually I have implemented my iterator classes (in C++) as follows
As seen, Iter is a two-way iterator, and the other two are one-way
iterators. (And there are correponding output iterators too, of course.)
There are also functions like toFirst(), toEnd(), etc (only Iter has
toFirst()). And for convenience, Iter also has functions like getNext()
and getPrev() that return the next/previous item without moving the
iterator. So there are quite many functions, which is not necessary good
;) (although many of them have default functionality that simply calls the
other "core" functions; for example, read() *could* be written with get()
I know very little about Ranges (when I have time, that will change), but
if I'm not mistaken, they hold and modify the beginning and end of the
iterated area? That's an interesting and unique approach. :) My classes
move a cursor inside the iterated area. Of course, with the Flow classes,
the beginning of the area is moved together with the cursor (as the cursor
cannot move backwards).
More information about the Digitalmars-d