56#ifndef AH_COMB_GENERATORS_H
57#define AH_COMB_GENERATORS_H
103template <
typename T,
class Compare = Aleph::less<T>>
159 const size_t n = a.
size();
170 for (
size_t i = 0; i <
k; ++i)
176 for (
size_t i = 0; i <
k; ++i)
177 combo.append(a[idx[i]]);
Combinatorics utilities: permutations, combinations, and matrix transposition.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Lazy sequence type (Aleph::Generator<T>) built on C++20 coroutines.
Simple dynamic array with automatic resizing and functional operations.
static Array create_reserved(const size_t cap)
Build an empty array with room for at least cap items.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
static Array create(const size_t n)
Create an array with n logical elements.
Lazy, single-pass sequence of T values produced by a coroutine.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
Main namespace for Aleph-w library functions.
bool next_combination_indices(Array< size_t > &idx, const size_t n, const bool reset_on_last=true)
Advance an index-combination [i0 < i1 < ... < i(k-1)] to the next one.
void timsort(T *a, const size_t n, const Compare &cmp=Compare())
Timsort — adaptive, stable, natural merge sort.
Aleph::Generator< Array< T > > lazy_permutations(Array< T > a, Compare cmp=Compare())
Lazily enumerate all permutations of a, in lexicographic order.
bool next_permutation(Array< T > &a, Compare cmp=Compare(), const bool reset_on_last=true)
Compute the next lexicographic permutation of an Array.
Aleph::Generator< Array< T > > lazy_combinations(Array< T > a, size_t k)
Lazily enumerate all k-element combinations of a's elements.
Dynamic array container with automatic resizing.
Comprehensive sorting algorithms and search utilities for Aleph-w.