开发者

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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜