54 const size_t count = std::min(
size,
size_t{256});
57 std::vector<int> values;
60 for (
size_t i = 0; i <
count; ++i)
62 const int value =
static_cast<int>(data[i] % 17) - 8;
65 values.push_back(
value);
68 auto ascending = values;
69 std::sort(ascending.begin(), ascending.end());
75 for (
size_t i = 0; i <
count; ++i)
76 if (sorted_array(i) != ascending[i] or dynarray(i) != ascending[i]
77 or array(i) != values[i])
80 auto descending = values;
81 std::sort(descending.begin(), descending.end(), std::greater<int>{});
82 const auto descending_array =
Aleph::sort(array, std::greater<int>{});
83 for (
size_t i = 0; i <
count; ++i)
84 if (descending_array(i) != descending[i])
87 std::vector<size_t> expected_indices(
count);
88 std::iota(expected_indices.begin(), expected_indices.end(), 0);
89 std::stable_sort(expected_indices.begin(), expected_indices.end(),
90 [&values](
size_t a,
size_t b)
92 return values[a] < values[b];
95 if (indices.size() !=
count)
97 for (
size_t i = 0; i <
count; ++i)
98 if (indices(i) != expected_indices[i])
High-level sorting functions for Aleph containers.
size_t size_t int32_t value
Simple dynamic array with automatic resizing and functional operations.
size_t size() const noexcept
Return the current dimension of array.
T & append()
Allocate a new entry to the end of array.
void reserve(const size_t l, const size_t r)
Allocate a range of entries.
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Check sorted values and stable index order for a byte sequence.
size_t size(Node *root) noexcept
See compute_cardinality_rec(Node * root).
Array< size_t > stable_argsort(const C &a, const Compare &cmp=Compare())
Return stable sorted-order indices for an array-like container.
DynArray< T > sort(const DynArray< T > &a, Cmp &&cmp=Cmp())
Returns a sorted copy of a DynArray.
DynArray< T > & in_place_sort(DynArray< T > &c, Cmp cmp=Cmp())
Sorts a DynArray in place.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.