Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-02-22 16:58:24


Meryl Silverburgh wrote:
> I have a map with key is a pair:
> typedef map < pair<int, int>, string> pairMapString;
>
> pair<int, int> key(1,3);
> map[key] = "one";
>
> How can I create a binary function using boost lamba which check the
> first value of the pair of the key of the map?
>
> void add(pairMapString;& myMap, int x) {
>
> iterator& itr = find_if(myMap.begin(), myMap.end(),
> bind(equal_to < int >(),
> bind(&BlockDataPairMap::value_type::first::value_type::first, _1 ) ,
> x) );

myMap.lower_bound( make_pair( x, INT_MIN ) ) should give you what you need
in logarithmic time, if I'm not mistaken.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net