Struct integer_partitions::Partitions
[−]
[src]
pub struct Partitions { /* fields omitted */ }
Iterates over the partitions of a given positive integer.
Methods
impl Partitions
[src]
fn new(n: usize) -> Partitions
[src]
fn next(&mut self) -> Option<&[usize]>
[src]
Advances the iterator and returns the next partition.
fn recycle(n: usize, vec: Vec<usize>) -> Partitions
[src]
Makes a new iterator, trying to avoid allocations.
Any vector can be passed to this function, since its contents
will be cleared and it will be filled with zeroes, but note
that the vector will still reallocate if its capacity is less
than n + 1
.
Panics
Panics if n < 1
.
fn end(self) -> Vec<usize>
[src]
Destroys the iterator and returns a vector for further use.
You only need to call this function if you want to reuse the vector for something else. Its contents will be in an undefined state, and so cannot be relied upon.