On Thu, Sep 24, 2009 at 7:04 PM, Anthony Foglia
I don't think it's that bad. The retrieval will be only slightly worse with an extra ".second" you'd need to add to get the vector of classA.
I would of course have to compare the int in that pair and if it matches return the extra ".second". Not bad but not optimal.
Yes, but it also will only compare the string value and not the int when using map::find as well.
I think by provided the LessFirstOfPair to the map gives the best of both worlds. When using the map functions I only compare the name value of the key. When needing to retrieve the value I can use std::find_if and by pass the given comparison. That gives the following code. Set up
typedef map< pair
, vector<classA>, LessFirstOfPair > cMap1;
Insersion
std::pair
find_if(map1.begin(), map1.end(), bind(&cMap1::value_type::first, _1) ==make_pair(givenName, intValue));\
Thanks for the help. Ryan