50 template <
typename T,
typename Allocator,
typename Compare = std::less<T>>
52 auto&
self = this->to_communicator();
53 size_t const oversampling_ratio = 16 *
static_cast<size_t>(std::log2(
self.size())) + (data.size() > 0 ? 1 : 0);
60 std::mt19937{self.rank() + self.size()}
67 std::sort(data.begin(), data.end(),
comp);
84 typename Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>>
86 using ValueType =
typename std::iterator_traits<RandomIt>::value_type;
88 auto&
self = this->to_communicator();
97 std::mt19937{asserting_cast<std::mt19937::result_type>(self.rank() + self.size())}
105 std::sort(data.begin(), data.end(),
comp);
106 std::copy(data.begin(), data.end(),
out);
118 template <
typename T,
typename Compare>
119 void pick_splitters(
size_t num_splitters,
size_t oversampling_ratio, std::vector<T>& global_samples, Compare comp) {
120 std::sort(global_samples.begin(), global_samples.end(), comp);
121 for (
size_t i = 0; i < num_splitters; i++) {
122 global_samples[i] = global_samples[oversampling_ratio * (i + 1)];
124 global_samples.resize(num_splitters);
134 template <
typename RandomIt,
typename T,
typename Compare>
135 auto build_buckets(RandomIt begin, RandomIt end, std::vector<T>& splitters, Compare comp)
136 -> std::vector<std::vector<T>> {
138 std::is_same_v<T, typename std::iterator_traits<RandomIt>::value_type>,
139 "Iterator value type and splitters do not match "
141 std::vector<std::vector<T>> buckets(splitters.size() + 1);
142 for (
auto it = begin; it != end; ++it) {
143 auto const bound = std::upper_bound(splitters.begin(), splitters.end(), *it, comp);
144 buckets[asserting_cast<size_t>(std::distance(splitters.begin(), bound))].push_back(*it);
void sort(RandomIt begin, RandomIt end, OutputIt out, Compare comp=Compare{})
Sort the elements in [begin, end) using a binary comparison function (std::less by default).
Definition sort.hpp:85
void sort(std::vector< T, Allocator > &data, Compare comp=Compare{})
Sort the vector based on a binary comparison function (std::less by default).
Definition sort.hpp:51
auto send_buf(internal::ignore_t< Data > ignore)
Generates a dummy send buf that wraps a nullptr.
Definition named_parameters.hpp:51