Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-comb-generators.H File Reference

Lazy (coroutine-based) permutation and combination enumeration. More...

#include <ah-comb.H>
Include dependency graph for ah-comb-generators.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Functions

template<typename T , class Compare = Aleph::less<T>>
Aleph::Generator< Array< T > > Aleph::lazy_permutations (Array< T > a, Compare cmp=Compare())
 Lazily enumerate all permutations of a, in lexicographic order.
 
template<typename T >
Aleph::Generator< Array< T > > Aleph::lazy_combinations (Array< T > a, size_t k)
 Lazily enumerate all k-element combinations of a's elements.
 

Detailed Description

Lazy (coroutine-based) permutation and combination enumeration.

ah-comb.H already exposes the step primitives that make lazy enumeration possible — next_permutation (lexicographic, STL-style) and next_combination_indices (k-subsets of [0, n)) both advance one step in place. This header wraps those steps into Aleph::Generator-based sequences so callers don't have to hand-roll the do { ... } while (next_*(...)) loop, and can break out early without having enumerated the rest.

The eager whole-sequence builders in ah-comb.H (build_perms, build_combs, and friends — Cartesian-product combinatorics over a DynList<DynList<T>>) are a different, unrelated feature (see the terminology note in ah-comb.H) and are untouched by this header.

See also
ah-comb.H next_permutation, next_combination_indices, combination_count, and the eager Cartesian-product builders.
ah-generator.H Aleph::Generator<T>, the underlying lazy sequence type.
Author
Leandro Rabindranath Leon

Definition in file ah-comb-generators.H.