Jonathan Mcdougall wrote:
I would like to make the map iterators cyclic. i.e.
If I I do a it-- when it = map.begin() then it gives
it.end()-1 and when I do it++ when it= it.end()-1, I would
like to get it.begin().
The problem is that usually, iterators do not know about their
containers, so you'll have to wrap the standard iterator along with
the container in a new class, which will implement all the operators.
These should simply forward the call to the iterator, except for ++, -- and
the like which will do the checking and wrap around.
In fact, that's not a problem at all IF the iterator is
constructed from a pair of iterators (begin,end). You
don't have to know where the iterator points to, just
when to wrap. In fact, the advantage of using an iterator
range is that it will also work if you're interested in
a subset of map values (e.g. only positive keys).
The only wrapper class is then the iterator wrapper. In
fact, there are libraries that do this already (VTL).
HTH,
Michiel Salters