map::lower_bound that returns a map
Is there a function that does the same thing as map::lower_bound
except it returns a new sub-map and not an iterator?
Edit: The functio开发者_C百科n should return a sub-map which contains all the values for which the key is equal to, or greater than a certain value (which is given as input to the function).
Something like this?
// Beware, brain-compiled code ahead!
template< typename K, typename V >
std::map<K,V> equal_or_greater(const std::map<K,V>& original, const K& k)
{
return std::map<K,V>( original.lower_bound(k), original.end() );
}
Edit: It seems you actually want upper_bound()
instead of lower_bound()
.
精彩评论