I am trying to decide if I should use a hash table of some sort. What I will have is a large amount of data in string format.
I will have many strings that will fall into categories, but have the same key value to access them.
An example would be if some strings fall into the category animal, I would use the string animal as a key but I would have many like this below as an example:
animal dog
animal cat
and so on.
And then maybe another called person
person tom
person joe
and son on
So I would want to search for animal or person and then list each value, so a search on person would return tom and joe.
Can you have multiple keys of the same value? It’s been a long time since I’ve had to think of a hash.
Is a hash good for this? If so is Boost or STL better?
Thanks
I can add more detail if this makes no sense, what I am asking.
Yep, a hash map supports multiple keys as its definition states. Keys are internally converted to indexes that are unique. The ideal is to have keys that are all different but this is seldom achievable unless the keys are fixed.
In your case, is there a restriction on why you did not choose “animal” and “person” to be keys?
In this case you can have a list of animals (dog, cat, camel, bird…) identified by a single key: animal and the same goes for person.