0

I've ordered QVector<QString> by qSort. I'd like to get index of specified QString, but qBinarySearch returns Java-style iterator allowing to move next/back or pointer to QString (because QVector::iterator is typedef T*). How can I get index of element without iterate for each element and check. Is the only way make own binary search method (I know how, but why invent wheel again?)?

patrykbajos
  • 384
  • 3
  • 17

1 Answers1

1

According to http://doc.qt.io/qt-5/qtalgorithms-obsolete.html those algorithms are obsolete, and you are recommended to use std::binary_search (or std::lower_bound) instead. They return random access iterators, so converting them to an index is cheap and easy.

Alan Stokes
  • 18,815
  • 3
  • 45
  • 64