40#ifndef GEOGRAM_BASIC_ALGORITHM
41#define GEOGRAM_BASIC_ALGORITHM
45#if defined(GEO_OS_LINUX) && defined(GEO_OPENMP)
46#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 4) && !defined(GEO_OS_ANDROID)
47#include <parallel/algorithm>
48#define GEO_USE_GCC_PARALLEL_STL
50#elif defined(GEO_OS_WINDOWS)
53#define GEO_USE_MSVC_PARALLEL_STL
88 template <
typename ITERATOR>
90 const ITERATOR& begin,
const ITERATOR& end
93#if defined(GEO_USE_GCC_PARALLEL_STL)
94 __gnu_parallel::sort(begin, end);
95#elif defined(GEO_USE_MSVC_PARALLEL_STL)
96 concurrency::parallel_sort(begin, end);
98 std::sort(begin, end);
101 std::sort(begin, end);
124 template <
typename ITERATOR,
typename CMP>
126 const ITERATOR& begin,
const ITERATOR& end,
const CMP& cmp
129#if defined(GEO_USE_GCC_PARALLEL_STL)
130 __gnu_parallel::sort(begin, end, cmp);
131#elif defined(GEO_USE_MSVC_PARALLEL_STL)
132 concurrency::parallel_sort(begin, end, cmp);
134 std::sort(begin, end, cmp);
137 std::sort(begin, end, cmp);
147 std::sort(v.begin(), v.end());
152 std::unique(v.begin(), v.end()), v.end()
162 template <
typename ITERATOR>
inline void sort_3(ITERATOR items) {
163 if (items[0]> items[1]) {
164 std::swap(items[0], items[1]);
166 if (items[1]> items[2]) {
167 std::swap(items[1], items[2]);
169 if (items[0]> items[1]) {
170 std::swap(items[0], items[1]);
180 template <
typename ITERATOR>
inline void sort_4(ITERATOR items) {
181 if (items[1] < items[0]) {
182 std::swap(items[0], items[1]);
184 if (items[3] < items[2]) {
185 std::swap(items[2], items[3]);
187 if (items[2] < items[0]) {
188 std::swap(items[0], items[2]);
189 std::swap(items[1], items[3]);
191 if (items[2] < items[1]) {
192 std::swap(items[1], items[2]);
194 if (items[3] < items[2]) {
195 std::swap(items[2], items[3]);
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
void sort_unique(VECTOR &v)
Sorts a vector and suppresses all duplicated elements.
bool uses_parallel_algorithm()
Checks whether parallel algorithms are used.
void sort_4(ITERATOR items)
Specialized sort routine for 4 elements.
void sort(const ITERATOR &begin, const ITERATOR &end)
Sorts elements in parallel.
void sort_3(ITERATOR items)
Specialized sort routine for 3 elements.