From 770ab026a80a038c77eb8957902208b2f6e76427 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 4 Nov 2013 16:22:10 +0100 Subject: Revert "QTest: use nth_element to calculate the median" This reverts commit 48586b2bac623605e9f300f8e5380e4f4b484dab. This causes problems in QtCreator without anyone being able to say why. Task-number: QTBUG-34397 Change-Id: I9ea5457724d5af8d87e0bc40e6615748daf9c04c Reviewed-by: Simon Hausmann --- src/testlib/qtestcase.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 260ace642e..e170d2a044 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1631,14 +1631,13 @@ QBenchmarkResult qMedian(const QList &container) if (count == 1) return container.front(); - const int middle = count / 2; - QList containerCopy = container; - const QList::iterator begin = containerCopy.begin(), mid = begin + middle, end = containerCopy.end(); - std::nth_element(begin, mid, end); + std::sort(containerCopy.begin(), containerCopy.end()); + + const int middle = count / 2; // ### handle even-sized containers here by doing an aritmetic mean of the two middle items. - return *mid; + return containerCopy.at(middle); } struct QTestDataSetter -- cgit v1.2.3