pub struct MultiSet { /* private fields */ }
Implementations
sourceimpl MultiSet
impl MultiSet
sourcepub fn new(n: usize, k: usize) -> Option<Self>
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.
sourcepub fn new_with_init(n: usize, k: usize) -> Option<Self>
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.
sourcepub fn init_first(&mut self)
pub fn init_first(&mut self)
This function initializes the multiset c to the lexicographically first multiset element, i.e. 0 repeated k times.
sourcepub fn init_last(&mut self)
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.
sourcepub fn copy(&self, dest: &mut MultiSet) -> Value
pub fn copy(&self, dest: &mut MultiSet) -> Value
This function copies the elements of the multiset self
into the multiset dest. The two
multisets must have the same size.
sourcepub fn get(&self, i: usize) -> usize
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.
sourcepub fn k(&self) -> usize
pub fn k(&self) -> usize
This function returns the number of elements (k) in the multiset self
.
sourcepub fn data(&self) -> &[usize]
pub fn data(&self) -> &[usize]
This function returns a pointer to the array of elements in the multiset self
.
sourcepub fn data_mut(&mut self) -> &mut [usize]
pub fn data_mut(&mut self) -> &mut [usize]
This function returns a pointer to the array of elements in the multiset self
.
sourcepub fn valid(&self) -> Value
pub fn valid(&self) -> 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.
sourcepub fn next(&mut self) -> Value
pub fn next(&mut self) -> Value
This function advances the multiset self to the next multiset element in lexicographic order
and returns Value::Success
. If no further multisets elements are available it returns
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.
sourcepub fn prev(&mut self) -> Value
pub fn prev(&mut self) -> 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.
pub fn print<W: Write>(&self, writer: &mut W) -> Result<()>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for MultiSet
impl !Send for MultiSet
impl !Sync for MultiSet
impl Unpin for MultiSet
impl UnwindSafe for MultiSet
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more