[英]std::map::lower_bound with a range
How can I get a lower_bound in a slice of a std::map
between two iterators (similar to std::lower_bound
) with logarithmic complexity (similar to std::map::lower_bound
)?如何在具有对数复杂度(类似于
std::map::lower_bound
)的两个迭代器(类似于std::lower_bound
)之间的std::map
切片中获得下界?
You can't do that.你不能那样做。
std::map
interface is not appropriate. std::map
接口不合适。 The solution is to use a flat data structure.解决方案是使用平面数据结构。 This can be a simple sorted
std::vector
or, more conveniently, boost::container::flat_map
.这可以是一个简单的排序
std::vector
,或者更方便的是boost::container::flat_map
。 Then, use std::lower_bound
as usual.然后,像往常一样使用
std::lower_bound
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.