Crate permutator[−][src]
This crate provide generic permutators. There's a function that can get a combination at any specific point of lexicographic ordered permutation. There's k-permutation function to generate all possible permutation. There's KPermutation struct that provide Iterator style to do k-Permutation over data. There's HeapPermutation struct that provide Iterator style permutation iterator. There's a combination function to generate all possible combination. There's a GosperCombination struct that provide Iterator style combination iterator.
This crate provides traits that introduce additional functions to [T]
and Vec<T>
.
See trait Permutation and trait Combination
for more detail.
The simplest and most efficient usage is call combination for combination, heap_permutation for permutation, and k_permutation function for k-permutation.
Structs
CombinationIterator | |
GosperCombination |
Create a combination iterator. It use Gosper's algorithm to pick a combination out of given data. The produced combination provide no lexicographic order. |
HeapPermutation |
Heap's permutation in iterator style implementation. It provide two way to iterate over the permutation. |
KPermutation |
k-Permutation over data of length n where k must be
less than n.
It'll attempt to permute given data by pick |
Traits
Combination |
Create a combination out of |
Permutation |
Create a permutation iterator that permute data in place. It return an object of HeapPermutation which can be used as iterator or manual iterate for higher throughput. |
Functions
cartesian_product |
Create a cartesian product over give slice. The result will be a slice
of borrowed |
combination |
Generate a combination out of given |
divide_factorial |
Calculate factorial for two factorial division. It'll return 1 if numerator is smaller or equals to denominator. Otherwise, it'll short circuit the calculation by calculate only the undivided remainder. |
factorial |
Calculate factorial from given value. |
get_cartesian_for |
Get a cartesian product at specific location.
If |
get_cartesian_size |
Calculate all possible cartesian combination size. It is always equals to size.pow(degree). |
get_permutation_for |
Get permutation at specific location.
If |
get_permutation_size |
Calculate all possible number of permutation. It's equals to size!/(size - 1). |
heap_permutation |
Heap permutation which permutate variable |
k_permutation |
Generate k-permutation over slice of |
multiply_factorial |
Calculate two factorial multiply on each other. It'll try to reduce calculation time by calculate the common value only once. |