Struct utote::Multiset

source ·
pub struct Multiset<N: Counter, const SIZE: usize> { /* private fields */ }
Expand description

A stack allocated multiset of unsigned integers.

Each index in the Multiset array corresponds to an element in the multiset. If the value at an index is 0 then there are no instances of the corresponding uint in the multiset. Because of this correspondence the order of the counts must remain consistent for any Multiset to behave consistently.

Examples

use utote::Multiset;

// A multiset of 5 elements, which can be counted up to u8::MAX
let mut multiset = Multiset::from([0u8, 3, 4, 0, 5]);
assert_eq!(multiset.total(), 12);

let equivalent_multiset = Multiset::<u8, 5>::from([0, 3, 4, 0, 5]);
assert_eq!(multiset, equivalent_multiset);

multiset.insert(2, 6);
assert_eq!(multiset, Multiset::from([0, 3, 6, 0, 5]));

for elem in multiset.iter() {
    println!("{}", elem);
}

assert_eq!(multiset.contains(0), false);
assert_eq!(multiset.contains(1), true);

Some common set-like operations:

use utote::Multiset;

let ms_sub: Multiset<u32, 3> = Multiset::from([0, 1, 1]);
let ms_super = Multiset::from([1, 1, 2]);

assert_eq!(ms_sub.is_subset(&ms_super), true);

assert_eq!(ms_sub.union(&ms_super), Multiset::from([1, 1, 2]));

assert_eq!(ms_super.is_proper_superset(&ms_sub), true);

// Any multiset where all counters are zero is equivalent to
// the empty multiset.
let empty: Multiset<u64, 2> = Multiset::from([0, 0]);
assert_eq!(empty, Multiset::empty());

Indexing

The Multiset type allows accessing values by index in the same manner that Vec does.

use utote::Multiset;
let multiset = Multiset::from([1u16, 2, 3]);
println!("{}", multiset[1]); // it will display '2'

As with slice, get and get_mut are provided (along with unchecked versions).

Using Generically

The Counter trait is provided to simplify using Multiset generically. Counter is implemented for all unsigned integers.

use utote::{Counter, Multiset};

fn generic_ms<T: Counter, const SIZE: usize>(ms: Multiset<T, SIZE>) {
    println!("{}", ms.is_empty());
}

Implementations§

source§

impl<N: Counter, const SIZE: usize> Multiset<N, SIZE>

source

pub const SIZE: usize = SIZE

The number of elements in the multiset.

source

pub fn len() -> usize

Returns the number of elements in the multiset.

source

pub fn new(data: [N; SIZE]) -> Multiset<N, SIZE>

Constructs a new Multiset.

This method is equivalent to calling Multiset::from with an array of the correct type.

Examples
use utote::Multiset;

let multiset = Multiset::new([1u8, 2, 3, 4]);
let multiset_from = Multiset::from([1, 2, 3, 4]);
assert_eq!(multiset, multiset_from);
source

pub fn empty() -> Self

Returns a Multiset of the given array size with all element counts set to zero.

Multiset::default will also construct an empty set.

Examples
use utote::Multiset;

let empty_multiset = Multiset::<u8, 4>::empty();
assert_eq!(empty_multiset, Multiset::from([0, 0, 0, 0]));
assert_eq!(empty_multiset, Multiset::default());
source

pub fn repeat(count: N) -> Self

Returns a Multiset of the given array size with all elements set to count.

Examples
use utote::Multiset;

let multiset = Multiset::<u8, 4>::repeat(5);
assert_eq!(multiset, Multiset::from([5, 5, 5, 5]))
source

pub fn from_elements<'a, I>(elements: I) -> Self
where I: IntoIterator<Item = &'a usize>,

Constructs a Multiset from an iterator of elements in the multiset, incrementing the count of each element as it occurs in the iterator.

Panics

If any item in the iterator is out of bounds of the Multiset.

Examples
use utote::Multiset;

let multiset = Multiset::<u8, 4>::from_elements(&[1, 1, 0, 2, 2, 2]);
assert_eq!(multiset, Multiset::from([1, 2, 3, 0]))
source

pub fn iter(&self) -> Iter<'_, N>

Return an Iter of the element counts in the Multiset.

source

pub fn iter_mut(&mut self) -> IterMut<'_, N>

Return a IterMut of the element counts in the Multiset.

source

pub fn clear(&mut self)

Sets all element counts in the multiset to zero.

Examples
use utote::Multiset;

let mut multiset = Multiset::<u8, 4>::from([1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);
source

pub fn contains(&self, elem: usize) -> bool

Returns true if elem has count > 0 in the multiset.

Examples
use utote::Multiset;

let multiset = Multiset::from([1u8, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);
source

pub unsafe fn contains_unchecked(&self, elem: usize) -> bool

Returns true if elem has count > 0 in the multiset, without doing bounds checking.

For a safe alternative see contains.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting boolean is not used.

Examples
use utote::Multiset;

let multiset = Multiset::from([1u8, 2, 0, 0]);

unsafe {
    assert_eq!(multiset.contains_unchecked(1), true);
    assert_eq!(multiset.contains_unchecked(3), false);
}
source

pub fn insert(&mut self, elem: usize, amount: N)

Set the count of elem in the multiset to amount.

Examples
use utote::Multiset;

let mut multiset = Multiset::from([1u8, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(&5));
source

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: N)

Set the count of elem in the multiset to amount, without doing bounds checking.

For a safe alternative see insert.

Safety

Calling this method with an out-of-bounds index is undefined behavior.

Examples
use utote::Multiset;

let mut multiset = Multiset::from([1u8, 2, 0, 0]);

unsafe {
    multiset.insert_unchecked(2, 5);
   assert_eq!(multiset.get(2), Some(&5));
}
source

pub fn remove(&mut self, elem: usize)

Set the count of elem in the multiset to zero.

Examples
use utote::Multiset;

let mut multiset = Multiset::from([1u8, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(&0));
source

pub unsafe fn remove_unchecked(&mut self, elem: usize)

Set the count of elem in the multiset to zero, without doing bounds checking.

For a safe alternative see remove.

Safety

Calling this method with an out-of-bounds index is undefined behavior.

Examples
use utote::Multiset;

let mut multiset = Multiset::from([1u8, 2, 0, 0]);
unsafe {
    multiset.remove_unchecked(1);
    assert_eq!(multiset.get(1), Some(&0));
}
source

pub fn get<I>(&self, index: I) -> Option<&I::Output>
where I: SliceIndex<[N]>,

Returns a reference to a count or subslice of counts depending on the type of index.

  • If given a position, returns a reference to the count at that position or None if out of bounds.
  • If given a range, returns the subslice corresponding to that range, or None if out of bounds.
Examples
use utote::Multiset;

let multiset = Multiset::from([1u8, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(&2));
assert_eq!(multiset.get(2..), Some(&[0, 0][..]));
assert_eq!(multiset.get(5), None);
assert_eq!(multiset.get(0..5), None);
source

pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output>
where I: SliceIndex<[N]>,

Returns a mutable reference to a count or subslice of counts depending on the type of index (see get) or None if the index is out of bounds.

Examples
use utote::Multiset;

let mut multiset = Multiset::from([1u8, 2, 4]);

if let Some(elem) = multiset.get_mut(1) {
    *elem = 42;
}
assert_eq!(multiset, Multiset::from([1u8, 42, 4]));
source

pub unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output
where I: SliceIndex<[N]>,

Returns a reference to a count or subslice of counts, without doing bounds checking.

For a safe alternative see get.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Examples
use utote::Multiset;

let multiset = Multiset::from([1u32, 2, 0, 0]);

unsafe {
    assert_eq!(multiset.get_unchecked(1), &2);
}
source

pub unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output
where I: SliceIndex<[N]>,

Returns a mutable reference to a count or subslice of counts, without doing bounds checking.

For a safe alternative see get_mut.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Examples
use utote::Multiset;

let mut multiset = Multiset::from([1u8, 2, 4]);

unsafe {
    let elem = multiset.get_unchecked_mut(1);
    *elem = 13;
}
assert_eq!(multiset, Multiset::from([1u8, 13, 4]));
source

pub fn intersection(&self, other: &Self) -> Self

Returns a multiset which is the intersection of self and other.

The Intersection of two multisets is the counts of elements which occurs in both. A intersection B is the multiset C where C[i] == min(A[i], B[i]) for all i in C.

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
let b = Multiset::from([0, 1, 3, 0]);
let c = Multiset::from([0, 1, 0, 0]);
assert_eq!(a.intersection(&b), c);
source

pub fn union(&self, other: &Self) -> Self

Returns a multiset which is the union of self and other.

The union of two multisets is the counts of elements which occur in either, without repeats. A union B is the multiset C where C[i] == max(A[i], B[i]) for all i in C.

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
let b = Multiset::from([0, 1, 3, 0]);
let c = Multiset::from([1, 2, 3, 0]);
assert_eq!(a.union(&b), c);
source

pub fn difference(&self, other: &Self) -> Self

Returns a multiset which is the difference of self and other.

The difference of this multiset and another is the count of elements in this and those that occur in this and other without repeats. A difference B is the multiset C where C[i] == min(A[i], B[i]) if A[i] > 0 and B[i] > 0, otherwise A[i] for all i in C.

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
let b = Multiset::from([0, 1, 3, 0]);
let c = Multiset::from([1, 1, 0, 0]);
assert_eq!(a.difference(&b), c);
source

pub fn symmetric_difference(&self, other: &Self) -> Self

Returns a multiset which is the symmetric_difference of self and other.

The symmetric_difference of two multisets is the count of elements that occur in either, and the count, without repeats that occurs in both. A symmetric_difference B is the multiset C where C[i] == min(A[i], B[i]) if A[i] > 0 and B[i] > 0, otherwise max(A[i], B[i]) for all i in C.

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
let b = Multiset::from([0, 1, 3, 0]);
let c = Multiset::from([1, 1, 3, 0]);
assert_eq!(a.symmetric_difference(&b), c);
source

pub fn count_non_zero(&self) -> usize

Returns the number of elements whose count is non-zero.

Examples
use utote::Multiset;

let multiset = Multiset::from([1u8, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);
source

pub fn count_zero(&self) -> usize

Returns the number of elements whose count is zero.

Examples
use utote::Multiset;

let multiset = Multiset::from([1u8, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);
source

pub fn is_singleton(&self) -> bool

Returns true if only one element in the multiset has a non-zero count.

Examples
use utote::Multiset;

let multiset = Multiset::from([0u8, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);
source

pub fn is_disjoint(&self, other: &Self) -> bool

Returns true if self is disjoint to other.

Multiset A is disjoint to B if A has no elements in common with B. A is disjoint B if min(A[i], B[i]) == 0 for all i in A.

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
assert_eq!(a.is_disjoint(&a), false);

let b = Multiset::from([0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&b), true);

let c = Multiset::from([0, 1, 1, 0]);
assert_eq!(a.is_disjoint(&c), false);
source

pub fn is_subset(&self, other: &Self) -> bool

Returns true if self is a subset of other.

Multiset A is a subset of B if all the element counts in A are less than or equal to the counts in B. A is subset B if A[i] <= B[i] for all i in A.

Examples
use utote::Multiset;

let a = Multiset::from([1u64, 2, 0, 0]);
assert_eq!(a.is_subset(&a), true);

let b = Multiset::from([1, 3, 0, 0]);
assert_eq!(a.is_subset(&b), true);

assert_eq!(a.is_subset(&Multiset::empty()), false);
source

pub fn is_superset(&self, other: &Self) -> bool

Returns true if self is a superset of other.

Multiset A is a subset of B if all the element counts in A are greater than or equal to the counts in B. A is superset B if A[i] >= B[i] for all i in A.

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
assert_eq!(a.is_superset(&a), true);

let b = Multiset::from([1, 1, 0, 0]);
assert_eq!(a.is_superset(&b), true);

assert_eq!(a.is_superset(&Multiset::empty()), true);
source

pub fn is_proper_subset(&self, other: &Self) -> bool

Returns true if self is a proper subset of other.

Multiset A is a proper subset of B if A is a subset of B and at least one element count of A is less than that element count in B. A is proper subset B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);

let b = Multiset::from([1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&b), true);
source

pub fn is_proper_superset(&self, other: &Self) -> bool

Returns true if self is a proper superset of other.

Multiset A is a proper superset of B if A is a superset of B and at least one element count of A is greater than that element count in B. A is proper superset B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);

let b = Multiset::from([1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&b), true);
source

pub fn is_any_lesser(&self, other: &Self) -> bool

Returns true if any element count in self is less than that element count in other.

A is any lesser B if there exists some i such that A[i] < B[i].

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 4, 0]);
assert_eq!(a.is_any_lesser(&a), false);

let b = Multiset::from([1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&b), true);
source

pub fn is_any_greater(&self, other: &Self) -> bool

Returns true if any element count in self is greater than that element count in other.

A is any greater B if there exists some i such that A[i] > B[i].

Examples
use utote::Multiset;

let a = Multiset::from([1u8, 2, 0, 0]);
assert_eq!(a.is_any_greater(&a), false);

let b = Multiset::from([1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&b), true);
source

pub fn is_empty(&self) -> bool

Returns true if all elements have a count of zero.

Examples
use utote::Multiset;

let multiset = Multiset::from([0u8, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(Multiset::<u8, 4>::empty().is_empty(), true);
source

pub fn total(&self) -> usize

The total or cardinality of a multiset is the sum of all element counts.

This function converts counts to usize to try and avoid overflows.

Examples
use utote::Multiset;

let multiset = Multiset::from([1u8, 2, 3, 4]);
assert_eq!(multiset.total(), 10);
source

pub fn elem_count_max(&self) -> (usize, &N)

Returns a tuple containing the element and a reference to the largest count in the multiset.

Examples
use utote::Multiset;

let multiset = Multiset::from([2u16, 0, 5, 3]);
assert_eq!(multiset.elem_count_max(), (2, &5));
source

pub fn elem_max(&self) -> usize

Returns the element with the largest count in the multiset.

Examples
use utote::Multiset;

let multiset = Multiset::from([2u8, 0, 5, 3]);
assert_eq!(multiset.elem_max(), 2);
source

pub fn count_max(&self) -> &N

Returns a reference to the largest count in the multiset.

Examples
use utote::Multiset;

let multiset = Multiset::from([2u8, 0, 5, 3]);
assert_eq!(multiset.count_max(), &5);
source

pub fn elem_count_min(&self) -> (usize, &N)

Returns a tuple containing the element and a reference to the smallest count in the multiset.

Examples
use utote::Multiset;

let multiset = Multiset::from([2u8, 0, 5, 3]);
assert_eq!(multiset.elem_count_min(), (1, &0));
source

pub fn elem_min(&self) -> usize

Returns the element with the smallest count in the multiset.

Examples
use utote::Multiset;

let multiset = Multiset::from([2u8, 0, 5, 3]);
assert_eq!(multiset.elem_min(), 1);
source

pub fn count_min(&self) -> &N

Returns a reference to the smallest count in the multiset.

Examples
use utote::Multiset;

let multiset = Multiset::from([2u8, 0, 5, 3]);
assert_eq!(multiset.count_min(), &0);
source

pub fn choose(&mut self, elem: usize)

Set all element counts, except for the given elem, to zero.

Examples
use utote::Multiset;

let mut multiset = Multiset::from([2u8, 0, 5, 3]);
multiset.choose(2);
let result = Multiset::from([0, 0, 5, 0]);
assert_eq!(multiset, result);
source

pub fn choose_random<T: RngCore>(&mut self, rng: &mut T)

Set all element counts, except for a random choice, to zero.

The choice is weighted by the counts of the elements, and unless the multiset is empty an element with non-zero count will always be chosen.

Examples
use utote::Multiset;
use rand::prelude::*;

let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = Multiset::from([2u8, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);
source

pub fn collision_entropy(&self) -> f64

Calculate the collision entropy of the multiset.

Examples
use utote::Multiset;

let multiset = Multiset::from([2u8, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844
Warning

Should not be used if Multiset::total or any counter in the multiset cannot be converted to f64. The conversions are handled by AsPrimitive<f64>.

source

pub fn shannon_entropy(&self) -> f64

Calculate the shannon entropy of the multiset. Uses ln rather than log2.

Examples
use utote::Multiset;

let multiset = Multiset::from([2u8, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179
Warning

Should not be used if Multiset::total or any counter in the multiset cannot be converted to f64. The conversions are handled by AsPrimitive<f64>.

Trait Implementations§

source§

impl<N: Counter, const SIZE: usize> Add<N> for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the + operator.
source§

fn add(self, rhs: N) -> Self::Output

Performs the + operation. Read more
source§

impl<N: Counter, const SIZE: usize> Add for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<N: Counter, const SIZE: usize> AddAssign<N> for Multiset<N, SIZE>

source§

fn add_assign(&mut self, rhs: N)

Performs the += operation. Read more
source§

impl<N: Counter, const SIZE: usize> AddAssign for Multiset<N, SIZE>

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<N: Counter, const SIZE: usize> Clone for Multiset<N, SIZE>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<N: Counter, const SIZE: usize> Debug for Multiset<N, SIZE>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<N: Counter, const SIZE: usize> Default for Multiset<N, SIZE>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<N: Counter, const SIZE: usize> Div<N> for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the / operator.
source§

fn div(self, rhs: N) -> Self::Output

Performs the / operation. Read more
source§

impl<N: Counter, const SIZE: usize> Div for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
source§

impl<N: Counter, const SIZE: usize> DivAssign<N> for Multiset<N, SIZE>

source§

fn div_assign(&mut self, rhs: N)

Performs the /= operation. Read more
source§

impl<N: Counter, const SIZE: usize> DivAssign for Multiset<N, SIZE>

source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
source§

impl<N: Counter, const SIZE: usize> From<&[N]> for Multiset<N, SIZE>

source§

fn from(slice: &[N]) -> Self

Converts to this type from the input type.
source§

impl<N: Counter, const SIZE: usize> From<&[N; SIZE]> for Multiset<N, SIZE>

source§

fn from(data: &[N; SIZE]) -> Self

Converts to this type from the input type.
source§

impl<'a, N: Counter, const SIZE: usize> From<&'a Multiset<N, SIZE>> for &'a [N]

source§

fn from(set: &'a Multiset<N, SIZE>) -> Self

Converts to this type from the input type.
source§

impl<'a, N: Counter, const SIZE: usize> From<&'a mut Multiset<N, SIZE>> for &'a mut [N]

source§

fn from(set: &'a mut Multiset<N, SIZE>) -> Self

Converts to this type from the input type.
source§

impl<N: Counter, const SIZE: usize> From<[N; SIZE]> for Multiset<N, SIZE>

source§

fn from(data: [N; SIZE]) -> Self

Converts to this type from the input type.
source§

impl<N: Counter, const SIZE: usize> From<Multiset<N, SIZE>> for [N; SIZE]

source§

fn from(set: Multiset<N, SIZE>) -> Self

Converts to this type from the input type.
source§

impl<'a, N: 'a + Counter, const SIZE: usize> FromIterator<&'a N> for Multiset<N, SIZE>

source§

fn from_iter<T: IntoIterator<Item = &'a N>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<N: Counter, const SIZE: usize> FromIterator<N> for Multiset<N, SIZE>

source§

fn from_iter<T: IntoIterator<Item = N>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<N: Counter, const SIZE: usize> Hash for Multiset<N, SIZE>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<N: Counter, I: SliceIndex<[N]>, const SIZE: usize> Index<I> for Multiset<N, SIZE>

§

type Output = <I as SliceIndex<[N]>>::Output

The returned type after indexing.
source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<N: Counter, I: SliceIndex<[N]>, const SIZE: usize> IndexMut<I> for Multiset<N, SIZE>

source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'a, N: Counter, const SIZE: usize> IntoIterator for &'a Multiset<N, SIZE>

§

type Item = &'a N

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, N>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, N: Counter, const SIZE: usize> IntoIterator for &'a mut Multiset<N, SIZE>

§

type Item = &'a mut N

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, N>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<N: Counter, const SIZE: usize> IntoIterator for Multiset<N, SIZE>

§

type Item = N

The type of the elements being iterated over.
§

type IntoIter = IntoIter<N, SIZE>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<N: Counter, const SIZE: usize> Mul<N> for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: N) -> Self::Output

Performs the * operation. Read more
source§

impl<N: Counter, const SIZE: usize> Mul for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<N: Counter, const SIZE: usize> MulAssign<N> for Multiset<N, SIZE>

source§

fn mul_assign(&mut self, rhs: N)

Performs the *= operation. Read more
source§

impl<N: Counter, const SIZE: usize> MulAssign for Multiset<N, SIZE>

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl<N: Counter, const SIZE: usize> PartialEq for Multiset<N, SIZE>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<N: Counter, const SIZE: usize> PartialOrd for Multiset<N, SIZE>

Partial order based on proper sub/super sets

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &Self) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &Self) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &Self) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &Self) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<N: Counter, const SIZE: usize> Rem<N> for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: N) -> Self::Output

Performs the % operation. Read more
source§

impl<N: Counter, const SIZE: usize> Rem for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
source§

impl<N: Counter, const SIZE: usize> RemAssign<N> for Multiset<N, SIZE>

source§

fn rem_assign(&mut self, rhs: N)

Performs the %= operation. Read more
source§

impl<N: Counter, const SIZE: usize> RemAssign for Multiset<N, SIZE>

source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
source§

impl<N: Counter, const SIZE: usize> Sub<N> for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: N) -> Self::Output

Performs the - operation. Read more
source§

impl<N: Counter, const SIZE: usize> Sub for Multiset<N, SIZE>

§

type Output = Multiset<N, SIZE>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<N: Counter, const SIZE: usize> SubAssign<N> for Multiset<N, SIZE>

source§

fn sub_assign(&mut self, rhs: N)

Performs the -= operation. Read more
source§

impl<N: Counter, const SIZE: usize> SubAssign for Multiset<N, SIZE>

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<N: Counter, const SIZE: usize> Copy for Multiset<N, SIZE>

source§

impl<N: Counter, const SIZE: usize> Eq for Multiset<N, SIZE>

Auto Trait Implementations§

§

impl<N, const SIZE: usize> RefUnwindSafe for Multiset<N, SIZE>
where N: RefUnwindSafe,

§

impl<N, const SIZE: usize> Send for Multiset<N, SIZE>
where N: Send,

§

impl<N, const SIZE: usize> Sync for Multiset<N, SIZE>
where N: Sync,

§

impl<N, const SIZE: usize> Unpin for Multiset<N, SIZE>
where N: Unpin,

§

impl<N, const SIZE: usize> UnwindSafe for Multiset<N, SIZE>
where N: UnwindSafe,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,