Custom iterator for a class based on two sets

Posted by Dan Hook on Stack Overflow See other posts from Stack Overflow or by Dan Hook
Published on 2010-04-20T15:21:34Z Indexed on 2010/04/20 15:23 UTC
Read the original article Hit count: 388

Filed under:
|
|

I have a class that contains two sets. They both contain the same key type but have different compare operations.

I would like to provide an iterator for the class that iterates through the elements of both sets. I want to start with one set, then when I increment an iterator pointing to the last element of the first set, I want to go to the first element of the second set. How do I do this? I would like to preserve the bidirectional iterator semantics of std::set, but if it turns out that implementing a forward iterator is much easier, so be it.

I'm willing to use the Boost Iterator library if that would help.

© Stack Overflow or respective owner

Related posts about c++

Related posts about iterator