diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2013-10-10 15:22:56 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-15 10:57:42 +0200 |
commit | f23e58322ef73731b74d19d82425cedab9512149 (patch) | |
tree | 94d7da2c5a20ab38e66a0ce79b795fa9c86f2008 /src/location/maps/qgeocameratiles.cpp | |
parent | 7f1067c97f55da45ffe3da7ec91ad32a2bcef255 (diff) | |
download | qtlocation-f23e58322ef73731b74d19d82425cedab9512149.tar.gz |
QtAlgorithms have been deprecated (2 of 2)
Convert to std algorithms to avoid warnings
Change-Id: I348e693fc14d67ad18fddfccd184858386373d23
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Diffstat (limited to 'src/location/maps/qgeocameratiles.cpp')
-rw-r--r-- | src/location/maps/qgeocameratiles.cpp | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/src/location/maps/qgeocameratiles.cpp b/src/location/maps/qgeocameratiles.cpp index a82e4394..1e799874 100644 --- a/src/location/maps/qgeocameratiles.cpp +++ b/src/location/maps/qgeocameratiles.cpp @@ -416,6 +416,74 @@ void QGeoCameraTilesPrivate::appendZIntersects(const QDoubleVector3D &start, } } +/***************************************************/ +/* Local copy of qSort & qSortHelper to suppress deprecation warnings + * following the deprecation of QtAlgorithms. The comparison has subtle + * differences which eluded detection so far. We just reuse old qSort for now. + **/ + +template <typename RandomAccessIterator, typename LessThan> +inline void localqSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan) +{ + if (start != end) + localqSortHelper(start, end, *start, lessThan); +} + +template <typename RandomAccessIterator, typename T, typename LessThan> +void localqSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan) +{ +top: + int span = int(end - start); + if (span < 2) + return; + + --end; + RandomAccessIterator low = start, high = end - 1; + RandomAccessIterator pivot = start + span / 2; + + if (lessThan(*end, *start)) + qSwap(*end, *start); + if (span == 2) + return; + + if (lessThan(*pivot, *start)) + qSwap(*pivot, *start); + if (lessThan(*end, *pivot)) + qSwap(*end, *pivot); + if (span == 3) + return; + + qSwap(*pivot, *end); + + while (low < high) { + while (low < high && lessThan(*low, *end)) + ++low; + + while (high > low && lessThan(*end, *high)) + --high; + + if (low < high) { + qSwap(*low, *high); + ++low; + --high; + } else { + break; + } + } + + if (lessThan(*low, *end)) + ++low; + + qSwap(*end, *low); + localqSortHelper(start, low, t, lessThan); + + start = low + 1; + ++end; + goto top; +} +/***************************************************/ + + // Returns the intersection of the plane of the map and the camera frustum as a right handed polygon Polygon QGeoCameraTilesPrivate::frustumFootprint(const Frustum &frustum) const { @@ -446,7 +514,8 @@ Polygon QGeoCameraTilesPrivate::frustumFootprint(const Frustum &frustum) const // - initial sort to remove duplicates sorter.base = points.first(); - qSort(points.begin(), points.end(), sorter); + localqSort(points.begin(), points.end(), sorter); + //std::sort(points.begin(), points.end(), sorter); for (int i = points.size() - 1; i > 0; --i) { if (points.at(i) == points.at(i - 1)) points.remove(i); |