简体   繁体   中英

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 )?

You can't do that. std::map interface is not appropriate. The solution is to use a flat data structure. This can be a simple sorted std::vector or, more conveniently, boost::container::flat_map . Then, use std::lower_bound as usual.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM