In the previous recipe, we made some kind of vocabulary, which is good when we need to work with pairs. But, what if we need much more advanced indexing? Let's make a program that indexes persons:
struct person { std::size_t id_; std::string name_; unsigned int height_; unsigned int weight_; person(std::size_t id, const std::string& name, unsigned int height, unsigned int weight) : id_(id) , name_(name) , height_(height) , weight_(weight) {} }; inline bool operator < (const person& p1, const person& p2) { return p1.name_ < p2.name_; }
We will need a lot of indexes, for example, by name, ID, height, and weight.