双映射结构实现?
我正在寻找一个标准的双映射结构 - 是否有在 std/boost/另一个标准 C++ 库中实现的结构?
当我说“双映射”时,我指的是可以通过键和“值”有效索引的映射(它实际上有两种键类型,而不是一种键类型和一种值类型)。
例如:
dualmap<int,string> m;
m[1] = "foo";
m["bar"] = 2
int a = m["bar"]; // a = 2
谢谢, 担
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你不这样做的话,有boost bimap不想要 boost multi index 的所有马力。
There's boost bimap if you don't want all the horsepower of boost multi index.
Boost 多索引可能就是您想要的 - 请参阅 http: //www.boost.org/doc/libs/1_42_0/libs/multi_index/doc/index.html
Boost multi-index is probably what you want - see http://www.boost.org/doc/libs/1_42_0/libs/multi_index/doc/index.html