summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-09-11 11:26:53 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-07-25 15:21:46 +0200
commit5026835690bac0ec0d3e0ef565e21b35329fdaf5 (patch)
treeb08747d4ca629c2d897b0482085c67105a3a412a /src/corelib
parent03ff5b35a5b852f56584484f449997f88e16668d (diff)
Re-implement QVector::count
There is no need for a custom algorithm as we can use std::count Change-Id: Id1ab514c7cd8f52efe49b27712121415d7ca4455 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qvector.h8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index c547cec7be..f09f1a3c41 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -810,13 +810,7 @@ bool QVector<T>::contains(const T &t) const
template <typename T>
int QVector<T>::count(const T &t) const
{
- int c = 0;
- T* b = d->begin();
- T* i = d->end();
- while (i != b)
- if (*--i == t)
- ++c;
- return c;
+ return int(std::count(cbegin(), cend(), t));
}
template <typename T>