Matching two strings

I have generated 1000s of strings. I want the program to match each of the string to 20 master strings and display those generated strings which match with any one of the master string. Can someone please explain how to do this with a small example?
Any method will probably involve taking a string from either list, then comparing it to every string in the other list. Then repeating for each string in the first list. Probably. If it's sorted, there are other ways, but this is the easiest way.
If you are speed obsessive.

Create a hash_map<string,int> and put your 20 master strings in there (just use 1 or something for the int values)

Then use hash_map::find on each of the other strings to determine which of the master strings it matches.

There is probably not much gain when you have only 20 master strings but when you have 1000000 master strings then this is the way to go.
Topic archived. No new replies allowed.