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 GosperCombination struct that provide Iterator style combination iterator.
The simplest usage is call k_permutation function.
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 |
Functions
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). |
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. |