Reimplement qBinaryFind in terms of std::lower_bound
qBinaryFind is not going to be deprecated now. This commits prepares the deprecation of the qLowerBound function. Change-Id: I6131582c981c151d632ad44305fe602c76735e14 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
94a7576658
commit
23d7f6ee5d
|
|
@ -43,6 +43,7 @@
|
|||
#define QALGORITHMS_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <algorithm>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -292,7 +293,7 @@ template <typename RandomAccessIterator, typename T>
|
|||
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
|
||||
{
|
||||
// Implementation is duplicated from QAlgorithmsPrivate.
|
||||
RandomAccessIterator it = qLowerBound(begin, end, value);
|
||||
RandomAccessIterator it = std::lower_bound(begin, end, value);
|
||||
|
||||
if (it == end || value < *it)
|
||||
return end;
|
||||
|
|
@ -506,7 +507,7 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator
|
|||
template <typename RandomAccessIterator, typename T, typename LessThan>
|
||||
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
|
||||
{
|
||||
RandomAccessIterator it = qLowerBoundHelper(begin, end, value, lessThan);
|
||||
RandomAccessIterator it = std::lower_bound(begin, end, value, lessThan);
|
||||
|
||||
if (it == end || lessThan(value, *it))
|
||||
return end;
|
||||
|
|
|
|||
Loading…
Reference in New Issue