1

I am searching for a (multi)map where there values are associated by different key types. Basically what was asked here for Java but for C++. Is there something like this already or do I have to implement it myself?


Another, more simple case (the above case would solve this already but there may be a more simple solution esp for this case):

I want a multimap where my values are all unique and ordered (the keys are also ordered of course) and I want to be able to do a search in the map for a specific value in O(log n) time. So I can get the associated key to a value in O(log n) time. And I can get the associated value to a key also in O(log n) time.

Community
  • 1
  • 1
Albert
  • 65,406
  • 61
  • 242
  • 386

2 Answers2

3

Boost Multi-Index.

tstenner
  • 10,080
  • 10
  • 57
  • 92
  • Exactly, thanks! Do you know if this is going to get into C++0x? Or sth similar? – Albert Sep 19 '10 at 14:30
  • Thought several of boost libraries are included in upcoming C++0x (in TR1 and TR2), but Multi-Index is not among them. – Liton Sep 19 '10 at 14:56
  • @Albert I doubt it, but since it'S a header-only library it's easy to use anyway. – tstenner Sep 19 '10 at 15:33
3

If you want to be able to search both by key and by value use boost.bimap.

If you need multiple keys use boost.multi-index.

Ferruccio
  • 98,941
  • 38
  • 226
  • 299