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();
171 for (
size_t i = 0; i <
k; ++i)
177 for (
size_t i = 0; i <
k; ++i)
178 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.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
void putn(const size_t n)
Reserve n additional logical slots in the array without value-initializing them.
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)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
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.