PDA

View Full Version : Replacing std::vector with QList: question about the iterator



papillon
22nd February 2015, 18:41
Hello, I'd like to ask a way to build or replicate, on a QList iterator, what std::lower_bound and std::max do using the STL library.
Thanks for any help.

yeye_olive
22nd February 2015, 18:54
You can use std::lower_bound with QList just as you would with std::vector, thanks to QList's STL-like iterators. See QList::begin(), QList::end(), QList::cbegin(), QList::cend(), QList::constBegin(), and QList::constEnd().

I do not understand what std::max has to do with iterators and containers. Were you thinking of std::max_element (in which case, the answer is the same as above)?

papillon
22nd February 2015, 20:55
Thanks for the information, I didn't know I could use the std:: calls like that. I indeed meant the std::max_element, but now I understood how to do it. Thank you.