bimap

Do we have a MultiBiMap ?

☆樱花仙子☆ 提交于 2019-11-28 04:20:06
问题 As we now, there is the concept of BiMap and multiMap but is there a multiBiMap ? so what do I mean by this. In multiMap you have one-to-many relationship between K and V, a single key can be associated to multiple value, hence the name. In bi map you have K,V pair which is bi-directional mean you can get V,K relationship as well. Like having a two regular maps but synchronized. I need a bi directional multi map where you combine these two concepts. 回答1: import java.util.Set; import com

Is there a more efficient implementation for a bidirectional map?

感情迁移 提交于 2019-11-28 03:54:23
I created a simple bidirectional map class that works by internally storing two std::map instances, with opposite key/value types, and providing an user-friendly interface: template<class T1, class T2> class Bimap { std::map<T1, T2> map1; std::map<T2, T1> map2; // ... }; Is there a more efficient method of implementing a bidirectional map that doesn't require twice the memory? How is a bimap usually implemented? EDIT: Should bimap element be mutable or immutable? (Changing one element in map1 should change the key in map2 , but keys are const and that's impossible - what's the solution?)

Is there a Boost.Bimap alternative in c++11?

不打扰是莪最后的温柔 提交于 2019-11-28 02:27:16
问题 Is there a usable alternative to Boost's bimap in C++0x? I would like to avoid Boost, but fully embrace C++11. If necessary, a slimmed down version of Boost's bimap would work for me (I need a constant bimap to switch between enums and corresponding strings) throughout my program. The map will be compile-time constant, so perhaps even two manually maintained maps aren't the optimal solution. Thanks! UPDATE: I found this on The Code Project, but it seems licensing may be an issue: http://www

Is there a more efficient implementation for a bidirectional map?

老子叫甜甜 提交于 2019-11-26 19:05:28
问题 I created a simple bidirectional map class that works by internally storing two std::map instances, with opposite key/value types, and providing an user-friendly interface: template<class T1, class T2> class Bimap { std::map<T1, T2> map1; std::map<T2, T1> map2; // ... }; Is there a more efficient method of implementing a bidirectional map that doesn't require twice the memory? How is a bimap usually implemented? EDIT: Should bimap element be mutable or immutable? (Changing one element in map1