tags:

views:

93

answers:

2

Hey, I'm looking for a standard dual-map structure - is there one implemented in std/boost/another standard C++ library?

When I say "dual-map" I mean a map which can be indexed efficiently both by the key and the "value" (it actually has two key types instead of one key type and one value type).

for example:

dualmap<int,string> m;
m[1] = "foo";
m["bar"] = 2
int a = m["bar"]; // a = 2

Thanks, Dan

+4  A: 

Boost multi-index is probably what you want - see http://www.boost.org/doc/libs/1_42_0/libs/multi_index/doc/index.html

anon
+10  A: 

There's boost bimap if you don't want all the horsepower of boost multi index.

piotr