Prepare QVector::contains() for sharing with QList::contains()
...by implementing it via std::find(). This might also enable STL implementations to choose a hand-optimized version of the algorithm for C++ builtin types. Change-Id: I86e94d63ff58332f2fa6eafb3c1baccd125a6f34 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
4adf5e1a9e
commit
023e6bd937
@ -791,12 +791,9 @@ int QVector<T>::lastIndexOf(const T &t, int from) const
|
||||
template <typename T>
|
||||
bool QVector<T>::contains(const T &t) const
|
||||
{
|
||||
T* i = d->begin();
|
||||
T* e = d->end();
|
||||
for (; i != e; ++i)
|
||||
if (*i == t)
|
||||
return true;
|
||||
return false;
|
||||
const T *b = d->begin();
|
||||
const T *e = d->end();
|
||||
return std::find(b, e, t) != e;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user