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
Giuseppe D'Angelo 2012-11-01 21:47:25 +01:00 committed by The Qt Project
parent 94a7576658
commit 23d7f6ee5d
1 changed files with 3 additions and 2 deletions

View File

@ -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;