Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Which collection class to use?

Which collection class to use?

Scheduled Pinned Locked Moved ATL / WTL / STL
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    paulb
    wrote on last edited by
    #1

    I have a set of int's and string's that have a one-to-one relationship with each other. There are never any duplicates on either side. Whats the best collection class to hold these pairs so that it is easy to find an entry given either the left or right hand value of the pair? std::map has a find function but it only finds on the 'key' field, I also need the equivalent for the 'value' field.

    J 1 Reply Last reply
    0
    • P paulb

      I have a set of int's and string's that have a one-to-one relationship with each other. There are never any duplicates on either side. Whats the best collection class to hold these pairs so that it is easy to find an entry given either the left or right hand value of the pair? std::map has a find function but it only finds on the 'key' field, I also need the equivalent for the 'value' field.

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Hi Paul, I wrote a class called bimap which seems to me is exactly what you're looking for. Check it out here[^] (Caveat, it does not work for MSVC 7.1.) The original idea of bimap, namely to maintain several access orders over the same set of elements, has been much expanded in a Boost library called Boost.MultiIndex[^]. A bidirectional map is just a particular case of what can be achieved with Boost.MultiIndex (though the syntax is not as terse as in bimap.) Boost.MultiIndex works for MSVC 7.1 and is generally much more powerful, so I'd recommend going for this. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups