< std::pair , "" - . , :
typedef std::pair<std::string, std::string> StringPair;
typedef std::set<StringPair> Set;
std::string const* find_first(Set const& s, std::string const& key) {
Set::const_iterator const it = s.lower_bound(std::make_pair(key, ""));
if (it == s.end() or it->first != key) { return 0; }
return &it->second;
}
lower_bound .
, , value.
end(), .it->first >= key, > ( )
, . , :
typedef std::pair<Set::const_iterator, Set::const_iterator> SetItPair;
SetItPair equal_range_first(Set const& s, std::string const& key) {
StringPair const p = std::make_pair(key, "");
return std::make_pair(s.lower_bound(p), s.upper_bound(p));
}
s, key. :
for (Set::const_iterator it = range.first; it != range.second; ++it) {
// do something
}
, lower_bound upper_bound .
lower_bound end(), upper_bound,lower_bound node, it->first > key, upper_bound node,
: , , , ... .