Searching in open-source projects (no-boost), I found a STL-like container bimap
here where implements a bidirectional-map. And there is multimap
in standard C++ libraries.
Note: A simple solution is using two multimap
s in bidirectional way. But it has not good performance. Because, for each insert
/ remove
/ find
operation we should perform them twice. In addition it allocates more memory.
Note II: The boost.bimap
is a good suggest from HostileFork and KerrekSB, And I will use it if there is no way. But before it I need find a non-boost and small size class library.
Boost.bimap lets you customize the type of collection for both values; both can be non-unique.
Why use random "CodeProject" code when there's a bimap in boost?
http://www.boost.org/doc/libs/1_42_0/libs/bimap/doc/html/index.html
Boost code tries to be close to the acceptable methodology of the standard library, and there's a vetting process through which eventually things get accepted. Maybe in the next standard, who knows?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.