MultiSet

Struct MultiSet 

Source
pub struct MultiSet { /* private fields */ }

Implementations§

Source§

impl MultiSet

Source

pub fn new(n: usize, k: usize) -> Option<Self>

This function allocates memory for a new multiset with parameters n, k. The multiset is not initialized and its elements are undefined. Use the function Self::new_with_init if you want to create a multiset which is initialized to the lexicographically first multiset element. A null pointer is returned if insufficient memory is available to create the multiset.

Source

pub fn new_with_init(n: usize, k: usize) -> Option<Self>

This function allocates memory for a new multiset with parameters n, k and initializes it to the lexicographically first multiset element. A null pointer is returned if insufficient memory is available to create the multiset.

Source

pub fn init_first(&mut self)

This function initializes the multiset c to the lexicographically first multiset element, i.e. 0 repeated k times.

Source

pub fn init_last(&mut self)

This function initializes the multiset c to the lexicographically last multiset element, i.e. n-1 repeated k times.

Source

pub fn copy(&self, dest: &mut MultiSet) -> Result<(), Value>

This function copies the elements of the multiset self into the multiset dest. The two multisets must have the same size.

Source

pub fn get(&self, i: usize) -> usize

This function returns the value of the i-th element of the multiset c. If i lies outside the allowed range of 0 to k-1 then the error handler is invoked and 0 is returned.

Source

pub fn n(&self) -> usize

This function returns the range (n) of the multiset self.

Source

pub fn k(&self) -> usize

This function returns the number of elements (k) in the multiset self.

Source

pub fn data(&self) -> &[usize]

This function returns a pointer to the array of elements in the multiset self.

Source

pub fn data_mut(&mut self) -> &mut [usize]

This function returns a pointer to the array of elements in the multiset self.

Source

pub fn valid(&self) -> Result<(), Value>

This function checks that the multiset self is valid. The k elements should lie in the range 0 to n-1, with each value occurring in non-decreasing order.

Returns OK(()) if valid.

Source

pub fn next(&mut self) -> Result<(), Value>

This function advances the multiset self to the next multiset element in lexicographic order and returns Ok(()). If no further multisets elements are available it returns Err(Value::Failure) and leaves self unmodified. Starting with the first multiset and repeatedly applying this function will iterate through all possible multisets of a given order.

Source

pub fn prev(&mut self) -> Result<(), Value>

This function steps backwards from the multiset self to the previous multiset element in lexicographic order, returning Value::Success. If no previous multiset is available it returns Value::Failure and leaves self unmodified.

Source

pub fn print<W: Write>(&self, writer: &mut W) -> Result<()>

Trait Implementations§

Source§

impl Drop for MultiSet

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.