Trait permutator::Combination
source · pub trait Combination<T> {
fn combination(&self, k: usize) -> CombinationIterator<'_, T> ⓘ;
}
Expand description
Create a combination out of T
Normally, it take a [T]
or Vec<T>
to create a combination.
Example
use permutator::Combination;
let data = [1, 2, 3, 4, 5];
data.combination(3).for_each(|c| {
// called multiple times.
// Each call have [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]
// [1, 2, 5], [1, 3, 5], [2, 3, 5], [1, 4, 5], [2, 4, 5],
// and [3, 4, 5] respectively.
println!("{:?}", c);
});
See Example implementation on foreign type.
Required Methods
sourcefn combination(&self, k: usize) -> CombinationIterator<'_, T> ⓘ
fn combination(&self, k: usize) -> CombinationIterator<'_, T> ⓘ
Create a CombinationIterator
of k
size out of self
.
See CombinationIterator for
how to use CombinationIterator
Return
A new CombinationIterator