Book Image

Learning Boost C++ Libraries

By : Arindam Mukherjee
Book Image

Learning Boost C++ Libraries

By: Arindam Mukherjee

Overview of this book

Table of Contents (19 chapters)
Learning Boost C++ Libraries
About the Author
About the Reviewers

Chapter 6. Bimap and Multi-index Containers

The Standard Library has ordered and unordered associative containers for storing objects and looking them up efficiently using some key. The key could be a text type, numeric type, or first-class objects. For ordered containers such as std::set and std::map, the keys must have a well-defined ordering relation that allows any set of keys to be sorted. For unordered containers, it must be possible to compute an integer hash value for each key, and additionally, determine whether any two keys are equivalent for some definition of equivalence. The key represents an index or criterion for lookup, and all the Standard Library associative containers support lookup using only a single criterion. In other words, you cannot efficiently look up objects using multiple, independent criteria.

Let us suppose you have a type called PersonEntry to describe a person. The PersonEntry type has attributes like name, age, phone number, and so on. You would end up storing...