- T1 const & find(T2 const & second) const {
- BOOST_ASSERT(!map.empty());
-
- // The idea is as follows:
- // find_if() will try to compare the data in the vector with
- // the value. The vector is made of pairs and the value has
- // the type of the second part of the pair.
- // We thus give find_if() an equal_to functor and assign to
- // its second post the value we want to compare. We now
- // compose the equal_to functor with the select2nd functor
- // to take only the second value of the pair to be compared.
- //
- // We can depict it as follows:
- // equal_to(select2nd(pair) , second)
- typename Map::const_iterator it =
- std::find_if(map.begin(), map.end(),
- ::boost::bind(std::equal_to<T2>(),
- ::boost::bind(&MapPair::second, _1),
- second)
- );
-
- if (it != map.end())
- return it->first;
- else {
- return default_t1;
- }
+ T1 const & find(T2 const & second) const
+ {
+ LASSERT(!map.empty(), /**/);
+ const_iterator it = map.begin();
+ const_iterator end = map.end();
+ for (; it != end; ++it)
+ if (it->second == second)
+ return it->first;
+ return default_t1;