Struct rgsl::types::combination::Combination
[−]
[src]
pub struct Combination { /* fields omitted */ }
Methods
impl Combination
[src]
fn new(n: usize, k: usize) -> Option<Combination>
This function allocates memory for a new combination with parameters n, k. The combination
is not initialized and its elements are undefined. Use the function
Combination::new_init_first
if you want to create a combination which is initialized to
the lexicographically first combination. A null pointer is returned if insufficient memory
is available to create the combination.
fn new_init_first(n: usize, k: usize) -> Option<Combination>
This function allocates memory for a new combination with parameters n, k and initializes it to the lexicographically first combination. A null pointer is returned if insufficient memory is available to create the combination.
fn init_first(&mut self)
This function initializes the combination c to the lexicographically first combination, i.e. (0,1,2,...,k-1).
fn init_last(&mut self)
This function initializes the combination c to the lexicographically last combination, i.e. (n-k,n-k+1,…,n-1).
fn copy(&self, dest: &mut Combination) -> Value
This function copies the elements of the combination self into the combination dest. The two combinations must have the same size.
fn get(&self, i: usize) -> usize
This function returns the value of the i-th element of the combination self. If i lies outside the allowed range of 0 to k-1 then the error handler is invoked and 0 is returned.
fn n(&self) -> usize
This function returns the range (n) of the combination self.
fn k(&self) -> usize
This function returns the number of elements (k) in the combination self.
fn as_slice<'r>(&'r self) -> &'r [usize]
This function returns a pointer to the array of elements in the combination self.
fn as_mut_slice<'r>(&'r mut self) -> &'r mut [usize]
This function returns a pointer to the array of elements in the combination self.
fn is_valid(&self) -> Value
This function checks that the combination self is valid. The k elements should lie in the range 0 to n-1, with each value occurring once at most and in increasing order.
fn next(&mut self) -> Value
This function advances the combination self to the next combination in lexicographic order
and returns Success
. If no further combinations are available it returns Failure and
leaves self unmodified. Starting with the first combination and repeatedly applying this
function will iterate through all possible combinations of a given order.
fn prev(&mut self) -> Value
This function steps backwards from the combination self to the previous combination in
lexicographic order, returning Success
. If no previous combination is available it returns
Failure
and leaves self unmodified.