was wondering what would be the best data structure to store a telephone directory when it has to be accessed via both name and number?
was wondering what would be the best data structure to store a telephone directory
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
in c++ you can have a look to boost::bimap (Bidirectionnal map) on this web page : http://www.boost.org/doc/libs/1_42_0/libs/bimap/doc/html/index.html
If you create a boost::bimap to store your directory all will be fine.
I think you can find an implementation of BiMap in Java.
Cheers,