简体   繁体   中英

Is there a way to get a pair having both the lower_bound and upper_bound in a sorted array?

If I have a std::vector having elements {1,1,1,2,2,2,3,3,3}

Is there a way to get a pair containing the lower_bound and upper_bound for value = 2?

Instead of me calling std::lower_bound and std::upper_bound separately.

Simply put, literally: std::equal_range

You could use std::equal_range .

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