Hello,
I have the following question:
I need to implement some task that takes a pair of strings, and do a dual search,
the first search is according to the first string, and if it was found there is a second search according to the second string.
For example, if the pair is <Ford, shield number> I need to first search some vector of cars name (with key "Ford"), and then search all the list of Ford to see if the shield number I got is there, and if not insert it to the Ford list.
I don't really know what is the best data structure to do it...a vector of pointers to list?
Or perhaps some map\set? the map<pair<string,string>> seem pretty complicated (For now, I don't use c++11). So if you could please suggest me how to do it in the simpiest way I will be gratefull (It's also possible that the first string is not yet in the vector..in this case I should insert it first, and then the shield).
Well if you have to search for a shield number under ford, an easy way is to use a map and a set. This will force a unique shield number for each string. I think that's what you were looking for...
Thanks for the quick answer!
But perhaps I didn't gave a perfect example, because as I said, I need the shield to be a string also (perhaps a better example is a singer name as the first string, and a song of his as the second string (then if the song in not in the singer list insert it, and otherwise do nothing..). How does your code change if the set contains string instead of int? thanks