In mappings it's solved by locking the index part; any modification that affects an index causes a copy to be made and the iterator(s) continue to use an otherwise unreferenced copy.
The problem with `< and `> on unordered collections is afaics mainly that it can be difficult to determine the relation between the two iterators. It might only be possible by stepping element by element from one of them to see if the other is encountered or not. The operation could still be useful, but it might be better to give it another name to avoid inadvertent misuse.
/ Martin Stjernholm, Roxen IS
Previous text:
2002-11-02 23:25: Subject: Re: Proposal for new ADT interface
What if you'd want to write code like
foo(collection c) { iterator i, j;
for (i = c->start(), j = j->end(); i<j; i++, j++) do_something_interesting(); // ^ iterator comparison }
I think there should be some way to do that for any collection, ordered or not. It may do unexpected things if do_something_interesting() makes changes to the collection (that's a general problem I'm not sure how it is best solved), but it should degrade in an ordered fasshion, e.g. it shouldn't turn into an infinite loop.
/ Niels Möller ()