January 11th, 2004, 08:44 PM
STL vectors vs. maps
I need a collection which will associate a string with an integer. The strings will be added numerically and so the number associated to the first string added will be 0, the second 1, etc. I was thinking I would use a vector, but the problem is that I then want to be able to search the collection for the string and find the integer related to it. A vector does not seem to have an existing search algorithm (am I wrong?). I could write one myself, but I was hoping there was another way.
I also looked at using a map, but I am finding the interface to a map to be needlessly complex. The example I have looked at shows:
where I would rather just use:
and searching the map involves iterators, and all sorts of other needless garbage when I just want to have a method like:
int find(string searchString);
So do I need to write a custom class or method, or is there something I am not seeing.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.