[−][src]Struct number_encoding::combinadics::Iter
Iterates over all k-combinations.
The k-combinations are iterated in value order:
let mut iter = Iter::new(k); for i in 0 .. combination(n, k) { assert_eq!(encode(iter.get()), i); iter.advance(); }
Examples
To iterate over all k
-combinations in a set of n
elements:
let mut iter = Iter::new(k); for _ in 0 .. combination(n, k) { process(iter.get()); iter.advance(); }
Methods
impl Iter
[src]
pub fn new(k: usize) -> Iter
[src]
Constructs an iterator.
pub fn new_from(xs: Vec<usize>) -> Iter
[src]
Constructs an iterator starting from a given k-combination.
Panics
Panics in debug mode if xs
is not increasing.
pub fn get(&self) -> &[usize]
[src]
Returns the current combination.
pub fn advance(&mut self)
[src]
Advances to the next combination.
Auto Trait Implementations
impl Send for Iter
impl Sync for Iter
impl Unpin for Iter
impl UnwindSafe for Iter
impl RefUnwindSafe for Iter
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,