Well.. I agree with the multi-index and it is the right way to do it. However, for a job interview, they probably want you to think about it and explain something, not just say use boost. If they ask about the internals of boost, it might be embarrassing if you can't explain it properly.
So, here is a possible solution.
First of all, do not use a hashtable for this. Phones and names can be easily sorted and you should probably use some balanced search tree, or a trie if you want interactive search (http://en.wikipedia.org/wiki/Trie). IMHO, a hashtable is a big waste of space in this case.
Let us assume that names are unique and numbers are unique. Then, you can do:
1- Data structure to hold your data
struct Phone {
// implement the phone here whatever they need
// assume that whatever representation used can be converted into a unique id (number)
}; //
struct PhoneBookEntry {
std::string name;
Phone number;
};
2- Create two trees one for the name and one for the phone
BalancedSearchTree<PhoneBookEntry> tree_by_name;
BalancedSearchTree<PhoneBookEntry> tree_by_number;
3- That is it. Look up each tree for whatever you need
bool PhoneBook::getByName(const std::string &name, PhoneBookEntry &o) {
tree_by_name.get(name, o);
return !o.empty();
}
bool PhoneBook::getByNumber(const Phone &p, PhoneBookEntry &o) {
tree_by_number.get(p, o);
return !o.empty();
}
Good luck