How can I use a hash-table (is it possible ?) to query for multiple parameters belonging to the same object?
Let me explain.
If I have the following array of objects
persons = [{name: "AA"}, {name: "BB"}, {name: "CA"}]
And I want to store them on a hash table, using the name
as the value
the
hashtable.put(persons[0]); // will compute hash("AA")
hashtable.put(persons[1]); // will compute hash("BB")
hashtable.put(persons[2]); // will compute hash("CA")
This would allow me to query my hashtable by name
very fast.
My question is, Is there any implementation of a hash-table that would allow me to query for multiple parameters for more complex objects like this
persons = [{name: "AA", city: "XX"}, {name: "BB", city: "YY"}, {name: "CA", city: "ZZ"}]
For example. Look for names = "AA"
and cities = "ZZ"
If hash-tables are not for this type of operations which algorithms or Data structures are the best for this type of operations?