c++ - 带有范围的 std::map::lower_bound
问题描述
如何在具有对数复杂度(类似于)的std::map
两个迭代器(类似于 )之间的 a 切片中获得下界?std::lower_bound
std::map::lower_bound
解决方案
你不能那样做。std::map
接口不合适。解决方案是使用平面数据结构。这可以是简单的排序std::vector
,或者更方便的是boost::container::flat_map
. 然后,std::lower_bound
照常使用。