首页 > 解决方案 > 带有范围的 std::map::lower_bound

问题描述

如何在具有对数复杂度(类似于)的std::map两个迭代器(类似于 )之间的 a 切片中获得下界?std::lower_boundstd::map::lower_bound

标签: c++stl

解决方案


你不能那样做。std::map接口不合适。解决方案是使用平面数据结构。这可以是简单的排序std::vector,或者更方便的是boost::container::flat_map. 然后,std::lower_bound照常使用。


推荐阅读