33#ifndef _GLIBCXX_PARALLEL_LIST_PARTITION_H
34#define _GLIBCXX_PARALLEL_LIST_PARTITION_H 1
48 template<
typename _IIter>
51 size_t& __count_to_two,
size_t& __range_length,
52 const bool __make_twice)
55 if (!__make_twice || __count_to_two < 2)
56 __shrink(__os_starts, __count_to_two, __range_length);
59 __os_starts.
resize((__os_starts.
size() - 1) * 2 + 1);
68 template<
typename _IIter>
71 size_t& __range_length)
73 for (
typename std::vector<_IIter>::size_type __i = 0;
74 __i <= (__os_starts.
size() / 2); ++__i)
75 __os_starts[__i] = __os_starts[__i * 2];
99 template<
typename _IIter,
typename _FunctorType>
102 _IIter* __starts,
size_t* __lengths,
const int __num_parts,
103 _FunctorType& __f,
int __oversampling = 0)
105 bool __make_twice =
false;
108 if (__oversampling == 0)
116 __os_starts[0] = __begin;
117 _IIter __prev = __begin, __it = __begin;
118 size_t __dist_limit = 0, __dist = 0;
119 size_t __cur = 1, __next = 1;
120 size_t __range_length = 1;
121 size_t __count_to_two = 0;
122 while (__it != __end)
125 for (; __cur < __os_starts.
size() and __it != __end; ++__cur)
127 for (__dist_limit += __range_length;
128 __dist < __dist_limit and __it != __end; ++__dist)
133 __os_starts[__cur] = __it;
143 __next = __os_starts.
size() / 2 + 1;
149 size_t __size_part = (__cur - 1) / __num_parts;
150 int __size_greater =
static_cast<int>((__cur - 1) % __num_parts);
151 __starts[0] = __os_starts[0];
156 for (
int __i = 1; __i < (__num_parts + 1 - __size_greater); ++__i)
158 __lengths[__i - 1] = __size_part * __range_length;
159 __index += __size_part;
160 __starts[__i] = __os_starts[__index];
164 for (
int __i = __num_parts + 1 - __size_greater; __i <= __num_parts;
167 __lengths[__i - 1] = (__size_part+1) * __range_length;
168 __index += (__size_part+1);
169 __starts[__i] = __os_starts[__index];
173 __lengths[__num_parts - 1] -= (__dist_limit - __dist);
End-user include file. Provides advanced settings and tuning options. This file is a GNU parallel ext...
GNU parallel code for public use.
size_t list_partition(const _IIter __begin, const _IIter __end, _IIter *__starts, size_t *__lengths, const int __num_parts, _FunctorType &__f, int __oversampling=0)
Splits a sequence given by input iterators into parts of almost equal size.
void __shrink_and_double(std::vector< _IIter > &__os_starts, size_t &__count_to_two, size_t &__range_length, const bool __make_twice)
Shrinks and doubles the ranges.
void __shrink(std::vector< _IIter > &__os_starts, size_t &__count_to_two, size_t &__range_length)
Combines two ranges into one and thus halves the number of ranges.
A standard container which offers fixed time access to individual elements in any order.
constexpr void resize(size_type __new_size)
Resizes the vector to the specified number of elements.
constexpr size_type size() const noexcept