If
1. the underlying collection is unmodified, and 2. the size of the collection is known
then it should be easy to associate an integer with each of the iterators. And comparison will do the right thing, if both iterators order the collection in a consistent way.
/ Niels Möller ()
Previous text:
2002-11-02 23:58: Subject: Re: Proposal for new ADT interface
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