Are iterators and ranges going to co-exist?
Peter Alexander
peter.alexander.au at gmail.com
Wed Jul 21 09:35:51 PDT 2010
== Quote from Andrei Alexandrescu
> I don't understand this. If all you need is access to one
individual
> element, why are pointers inadequate for non-arraylike
containers?
> Knowledge of the container's topology is needed only if moving
the
> iterator around is needed.
> Andrei
There's lots of reasons you need a cursor rather than just a
pointer. I've already mentioned most of them.
- You can't do myContainer.remove(pointer). You need the cursor
for efficient removal.
- You can't do the random_shuffle thing I mentioned earlier with
just pointers.
- You can't implement cycle_to with pointers (whether you need it
or not).
- You can't use pointers to construct ranges. For example, if you
had a "Cursor findFirst(Range r)", you could use the value to
construct before and after ranges. Pointers are no use here.
More information about the Digitalmars-d
mailing list