Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:45:32+00:00 2026-05-14T07:45:32+00:00

I have a class that contains two sets. They both contain the same key

  • 0

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.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:45:32+00:00Added an answer on May 14, 2026 at 7:45 am

    I implemented a very similar iterator using the boost libraries:

    Have a read from here:
    http://www.boost.org/doc/libs/1_42_0/libs/iterator/doc/iterator_facade.html#a-basic-iterator-using-iterator-facade

    For a forward iterator you will need to implement the operator++, to change that to a bidirectional iterator you need to implement operator–.

    The implementation is up to you, but all is explained in the documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Maps that contain the same type of Objects: Map<String, TaskJSO> a
I have a class that contains objects of two other classes. I need one
I have an app that contains two buttons, both that are suppose to take
I have an ObservableCollection<Object> that contains two different types. I want to bind this
I have a class that contains two arraylists which I'm trying to store objects
I have a class that contains a collection. The two instances of the class
I have a User-class that contains a HashMap to map between two custom objects.
I have defined a class TestObject that contains two simple properties num and name.
I have json with field that contains two different types. fields:[{value:ZIELONE OKO},{value:{@nil:true}}] I have
I have this type that contains two overloads of a generic method. I like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.