40#ifndef GEOGRAM_BASIC_ALGORITHM
41#define GEOGRAM_BASIC_ALGORITHM
48#ifdef GEO_PARALLEL_STL
84 template <
typename ITERATOR>
86 const ITERATOR& begin,
const ITERATOR& end
88#ifdef GEO_PARALLEL_STL
90 std::sort(std::execution::par, begin, end);
94 std::sort(begin, end);
117 template <
typename ITERATOR,
typename CMP>
119 const ITERATOR& begin,
const ITERATOR& end,
const CMP& cmp
121#ifdef GEO_PARALLEL_STL
123 std::sort(std::execution::par, begin, end, cmp);
127 std::sort(begin, end, cmp);
137 std::sort(v.begin(), v.end());
142 std::unique(v.begin(), v.end()), v.end()
152 template <
typename ITERATOR>
inline void sort_3(ITERATOR items) {
153 if (items[0]> items[1]) {
154 std::swap(items[0], items[1]);
156 if (items[1]> items[2]) {
157 std::swap(items[1], items[2]);
159 if (items[0]> items[1]) {
160 std::swap(items[0], items[1]);
170 template <
typename ITERATOR>
inline void sort_4(ITERATOR items) {
171 if (items[1] < items[0]) {
172 std::swap(items[0], items[1]);
174 if (items[3] < items[2]) {
175 std::swap(items[2], items[3]);
177 if (items[2] < items[0]) {
178 std::swap(items[0], items[2]);
179 std::swap(items[1], items[3]);
181 if (items[2] < items[1]) {
182 std::swap(items[1], items[2]);
184 if (items[3] < items[2]) {
185 std::swap(items[2], items[3]);
196 template <
typename ITERATOR>
200 std::shuffle(begin, end, urng);
Common include file, providing basic definitions. Should be included before anything else by all head...
int32 random_int32()
Returns a 32 bits integer between 0 and RAND_MAX.
Global Vorpaline namespace.
void sort_unique(VECTOR &v)
Sorts a vector and suppresses all duplicated elements.
void sort_4(ITERATOR items)
Specialized sort routine for 4 elements.
void sort(const ITERATOR &begin, const ITERATOR &end)
Sorts elements in parallel.
bool uses_parallel_algorithm(size_t size=0)
Checks whether parallel algorithms are used.
void sort_3(ITERATOR items)
Specialized sort routine for 3 elements.
void random_shuffle(const ITERATOR &begin, const ITERATOR &end)
Applies a random permutation to a sequence.
Types and functions for numbers manipulation.