Struct utote::Multiset[][src]

pub struct Multiset<N, const SIZE: usize> { /* fields omitted */ }

Multiset! yay

Implementations

impl<const SIZE: usize> Multiset<u8, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::empty();

pub const fn repeat(elem: u8) -> Self[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::repeat(5);

pub fn from_slice(slice: &[u8]) -> Self[src]

Returns a Multiset from a slice of the given array size.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu8;
assert_eq!(MSu8::<4>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u8>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

pub unsafe fn get_unchecked(self, elem: usize) -> u8[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 2, 3, 0]);
let c = MSu8::<4>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 2, 3, 0]);
let c = MSu8::<4>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u8[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u8[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu8::<4>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 4, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u8[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.

pub fn argmax(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

pub fn max(&self) -> u8[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

pub fn argmin(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

pub fn min(&self) -> u8[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

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

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

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu8::<4>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu8;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

impl<const SIZE: usize> Multiset<u16, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::empty();

pub const fn repeat(elem: u16) -> Self[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::repeat(5);

pub fn from_slice(slice: &[u16]) -> Self[src]

Returns a Multiset from a slice of the given array size.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu8;
assert_eq!(MSu8::<4>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u16>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

pub unsafe fn get_unchecked(self, elem: usize) -> u16[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 2, 3, 0]);
let c = MSu8::<4>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 2, 3, 0]);
let c = MSu8::<4>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u16[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u16[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu8::<4>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 4, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u16[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.

pub fn argmax(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

pub fn max(&self) -> u16[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

pub fn argmin(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

pub fn min(&self) -> u16[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

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

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

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu8::<4>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu8;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

impl<const SIZE: usize> Multiset<u32, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::empty();

pub const fn repeat(elem: u32) -> Self[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::repeat(5);

pub fn from_slice(slice: &[u32]) -> Self[src]

Returns a Multiset from a slice of the given array size.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu8;
assert_eq!(MSu8::<4>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u32>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

pub unsafe fn get_unchecked(self, elem: usize) -> u32[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 2, 3, 0]);
let c = MSu8::<4>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 2, 3, 0]);
let c = MSu8::<4>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu8::<4>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 4, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u32[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.

pub fn argmax(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

pub fn max(&self) -> u32[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

pub fn argmin(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

pub fn min(&self) -> u32[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

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

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

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu8::<4>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu8;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

impl<const SIZE: usize> Multiset<u64, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::empty();

pub const fn repeat(elem: u64) -> Self[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::repeat(5);

pub fn from_slice(slice: &[u64]) -> Self[src]

Returns a Multiset from a slice of the given array size.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu8;
assert_eq!(MSu8::<4>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u64)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u64)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u64>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

pub unsafe fn get_unchecked(self, elem: usize) -> u64[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 2, 3, 0]);
let c = MSu8::<4>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 2, 3, 0]);
let c = MSu8::<4>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u64[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u64[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu8::<4>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 4, 0]);
let b = MSu8::<4>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu8;
let a = MSu8::<4>::from_slice(&[1, 2, 0, 0]);
let b = MSu8::<4>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u64[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.

pub fn argmax(&self) -> (usize, u64)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

pub fn max(&self) -> u64[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

pub fn argmin(&self) -> (usize, u64)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

pub fn min(&self) -> u64[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

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

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

Examples

use utote::MSu8;
let mut multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu8::<4>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu8;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu8::<4>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

impl<const SIZE: usize> Multiset<u8, SIZE> where
    f64: From<u8>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

impl<const SIZE: usize> Multiset<u16, SIZE> where
    f64: From<u16>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

impl<const SIZE: usize> Multiset<u32, SIZE> where
    f64: From<u32>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu8;
let multiset = MSu8::<4>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

impl<const SIZE: usize> Multiset<Simd<[u8; 2]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u8) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u8]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u8>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u8[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u8[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u8[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u8[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u8; 4]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u8) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u8]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u8>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u8[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u8[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u8[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u8[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u8; 8]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u8) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u8]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u8>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u8[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u8[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u8[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u8[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u8; 16]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u8) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u8]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u8>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u8[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u8[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u8[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u8[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u8; 32]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u8) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u8]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u8>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u8[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u8[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u8[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u8[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u8; 64]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u8) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u8]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u8)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u8>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u8[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u8[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u8[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u8)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u8[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u16; 2]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u16) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u16]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u16>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u16[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u16[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u16[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u16[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u16; 4]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u16) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u16]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u16>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u16[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u16[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u16[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u16[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u16; 8]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u16) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u16]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u16>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u16[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u16[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u16[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u16[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u16; 16]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u16) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u16]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u16>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u16[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u16[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u16[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u16[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u16; 32]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u16) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u16]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u16)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u16>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u16[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u16[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u16[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u16)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u16[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u32; 2]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u32) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u32]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u32>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u32[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u32[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u32[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u32[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u32; 4]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u32) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u32]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u32>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u32[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u32[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u32[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u32[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u32; 8]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u32) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u32]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u32>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u32[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u32[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u32[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u32[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u32; 16]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u32) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u32]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u32)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u32>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u32[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u32[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u32[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u32)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u32[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u64; 2]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u64) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u64]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u64)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u64)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u64>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u64[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u64[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u64)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u64[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u64)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u64[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u64; 4]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u64) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u64]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u64)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u64)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u64>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u64[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u64[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u64)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u64[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u64)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u64[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u64; 8]>, SIZE>[src]

pub const SIZE: usize[src]

pub const fn empty() -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::empty();

pub const fn repeat(elem: u64) -> Self[src]

Returns a Multiset of the given array * SIMD vector size with all elements set to elem.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::repeat(5);

pub fn from_slice(slice: &[u64]) -> Self[src]

Returns a Multiset from a slice of the given array * SIMD vector size.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);

pub const fn len() -> usize[src]

The number of elements in the multiset.

Examples

use utote::MSu32x2;
assert_eq!(MSu32x2::<2>::len(), 4);

pub fn clear(&mut self)[src]

Sets all element counts in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
multiset.clear();
assert_eq!(multiset.is_empty(), true);

pub fn contains(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.contains(1), true);
assert_eq!(multiset.contains(3), false);
assert_eq!(multiset.contains(5), false);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn contains_unchecked(self, elem: usize) -> bool[src]

Checks that a given element has at least one member in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.contains_unchecked(1) }, true);
assert_eq!(unsafe { multiset.contains_unchecked(3) }, false);
// unsafe { multiset.contains_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn insert(&mut self, elem: usize, amount: u64)[src]

Set the counter of an element in the multiset to amount.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.insert(2, 5);
assert_eq!(multiset.get(2), Some(5));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

pub unsafe fn insert_unchecked(&mut self, elem: usize, amount: u64)[src]

Set the counter of an element in the multiset to amount without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.insert_unchecked(2, 5) };
assert_eq!(multiset.get(2), Some(5));
// unsafe { multiset.insert_unchecked(5, 10) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

Set the counter of an element in the multiset to zero.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
multiset.remove(1);
assert_eq!(multiset.get(1), Some(0));

Notes:

  • The implementation replaces values from the underlying SIMD vector.

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

Set the counter of an element in the multiset to zero without bounds checks.

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
unsafe { multiset.remove_unchecked(1) };
assert_eq!(multiset.get(1), Some(0));
// unsafe { multiset.remove_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation replaces values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

pub fn get(self, elem: usize) -> Option<u64>[src]

Returns the amount of an element in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(multiset.get(1), Some(2));
assert_eq!(multiset.get(3), Some(0));
assert_eq!(multiset.get(5), None);

Notes:

  • The implementation extracts values from the underlying SIMD vector.

pub unsafe fn get_unchecked(self, elem: usize) -> u64[src]

Returns the amount of an element in the multiset without bounds checks.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
assert_eq!(unsafe { multiset.get_unchecked(1) }, 2);
assert_eq!(unsafe { multiset.get_unchecked(3) }, 0);
// unsafe { multiset.get_unchecked(5) };  NOT SAFE!!!

Notes:

  • The implementation extracts values from the underlying SIMD vector.

Safety

Does not run bounds check on whether this element is an index in the underlying array.

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

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

The Intersection of two multisets A & B is defined as the multiset C where C[0] == min(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[0, 2, 0, 0]);
assert_eq!(a.intersection(&b), c);

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

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

The union of two multisets A & B is defined as the multiset C where C[0] == max(A[0], B[0]).

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 2, 3, 0]);
let c = MSu32x2::<2>::from_slice(&[1, 2, 3, 0]);
assert_eq!(a.union(&b), c);

pub fn count_zero(&self) -> u32[src]

Return the number of elements whose counter is zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_zero(), 3);

pub fn count_non_zero(&self) -> u32[src]

Return the number of elements whose counter is non-zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 0, 0, 0]);
assert_eq!(multiset.count_non_zero(), 1);

pub fn is_empty(&self) -> bool[src]

Check whether all elements have a count of zero.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 0, 0, 0]);
assert_eq!(multiset.is_empty(), true);
assert_eq!(MSu32x2::<2>::empty().is_empty(), true);

pub fn is_singleton(&self) -> bool[src]

Check whether only one element has a non-zero count.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[0, 5, 0, 0]);
assert_eq!(multiset.is_singleton(), true);

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

Returns true if self has no elements in common with other.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[0, 0, 3, 4]);
assert_eq!(a.is_disjoint(&a), false);
assert_eq!(a.is_disjoint(&b), true);

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

Check whether self is a subset of other.

Multiset A is a subset of B if A[i] <= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_subset(&a), true);
assert_eq!(a.is_subset(&b), true);

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

Check whether self is a superset of other.

Multiset A is a superset of B if A[i] >= B[i] for all i in A.

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_superset(&a), true);
assert_eq!(a.is_superset(&b), true);

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

Check whether self is a proper subset of other.

Multiset A is a proper subset of B if A[i] <= B[i] for all i in A and there exists j such that A[j] < B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_proper_subset(&a), false);
assert_eq!(a.is_proper_subset(&b), true);

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

Check whether self is a proper superset of other.

Multiset A is a proper superset of B if A[i] >= B[i] for all i in A and there exists j such that A[j] > B[j].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 0, 0]);
assert_eq!(a.is_proper_superset(&a), false);
assert_eq!(a.is_proper_superset(&b), true);

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

Check whether any element of self is less than an element of other.

True if the exists some i such that A[i] < B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 4, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 3, 0, 0]);
assert_eq!(a.is_any_lesser(&a), false);
assert_eq!(a.is_any_lesser(&b), true);

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

Check whether any element of self is greater than an element of other.

True if the exists some i such that A[i] > B[i].

Examples

use utote::MSu32x2;
let a = MSu32x2::<2>::from_slice(&[1, 2, 0, 0]);
let b = MSu32x2::<2>::from_slice(&[1, 1, 4, 0]);
assert_eq!(a.is_any_greater(&a), false);
assert_eq!(a.is_any_greater(&b), true);

pub fn total(&self) -> u64[src]

The total or cardinality of a multiset is the sum of all its elements member counts.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[1, 2, 3, 4]);
assert_eq!(multiset.total(), 10);

Notes:

  • This may overflow.
  • The implementation uses a horizontal operation on SIMD vectors.

pub fn argmax(&self) -> (usize, u64)[src]

Returns a tuple containing the (element, corresponding largest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmax(), (2, 5));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imax(&self) -> usize[src]

Returns the element with the largest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imax(), 2);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn max(&self) -> u64[src]

Returns the largest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.max(), 5);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

pub fn argmin(&self) -> (usize, u64)[src]

Returns a tuple containing the (element, corresponding smallest counter) in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.argmin(), (1, 0));

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn imin(&self) -> usize[src]

Returns the element with the smallest count in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.imin(), 1);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

pub fn min(&self) -> u64[src]

Returns the smallest counter in the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
assert_eq!(multiset.min(), 0);

Notes:

  • The implementation uses a horizontal operation on the underlying SIMD vectors.

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

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

Examples

use utote::MSu32x2;
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose(2);
let result = MSu32x2::<2>::from_slice(&[0, 0, 5, 0]);
assert_eq!(multiset, result);

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

Set all element counts, except for a random choice, to zero. The choice is weighted by the counts of the elements.

Examples

use utote::MSu32x2;
use rand::prelude::*;
let rng = &mut SmallRng::seed_from_u64(thread_rng().next_u64());
let mut multiset = MSu32x2::<2>::from_slice(&[2, 0, 5, 3]);
multiset.choose_random(rng);
assert_eq!(multiset.is_singleton(), true);

Notes:

  • The implementation extracts values from the underlying SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u8; 2]>, SIZE> where
    f64: From<u8>,
    f64x2: From<u8x2>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u8; 4]>, SIZE> where
    f64: From<u8>,
    f64x4: From<u8x4>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u8; 8]>, SIZE> where
    f64: From<u8>,
    f64x8: From<u8x8>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u16; 2]>, SIZE> where
    f64: From<u16>,
    f64x2: From<u16x2>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u16; 4]>, SIZE> where
    f64: From<u16>,
    f64x4: From<u16x4>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u16; 8]>, SIZE> where
    f64: From<u16>,
    f64x8: From<u16x8>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u32; 2]>, SIZE> where
    f64: From<u32>,
    f64x2: From<u32x2>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u32; 4]>, SIZE> where
    f64: From<u32>,
    f64x4: From<u32x4>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

impl<const SIZE: usize> Multiset<Simd<[u32; 8]>, SIZE> where
    f64: From<u32>,
    f64x8: From<u32x8>, 
[src]

pub fn collision_entropy(&self) -> f64[src]

Calculate the collision entropy of the multiset.

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.collision_entropy();
// approximate: result == 1.415037499278844

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

pub fn shannon_entropy(&self) -> f64[src]

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

Examples

use utote::MSu32x2;
let multiset = MSu32x2::<2>::from_slice(&[2, 1, 1, 0]);
let result = multiset.shannon_entropy();
// approximate: result == 1.0397207708399179

Notes:

  • The implementation uses a horizontal operation on SIMD vectors.

Trait Implementations

impl<N, const SIZE: usize> Add<Multiset<N, SIZE>> for Multiset<N, SIZE> where
    N: Add + Copy,
    <N as Add>::Output: Copy
[src]

type Output = Multiset<<N as Add>::Output, SIZE>

The resulting type after applying the + operator.

impl<N, const SIZE: usize> AddAssign<Multiset<N, SIZE>> for Multiset<N, SIZE> where
    N: AddAssign + Copy
[src]

impl<N: Clone, const SIZE: usize> Clone for Multiset<N, SIZE>[src]

impl<N: Copy, const SIZE: usize> Copy for Multiset<N, SIZE>[src]

impl<N: Debug, const SIZE: usize> Debug for Multiset<N, SIZE>[src]

impl<N, const SIZE: usize> Div<Multiset<N, SIZE>> for Multiset<N, SIZE> where
    N: Div + Copy,
    <N as Div>::Output: Copy
[src]

type Output = Multiset<<N as Div>::Output, SIZE>

The resulting type after applying the / operator.

impl<N, const SIZE: usize> DivAssign<Multiset<N, SIZE>> for Multiset<N, SIZE> where
    N: DivAssign + Copy
[src]

impl<N, const SIZE: usize> Eq for Multiset<N, SIZE> where
    Multiset<N, SIZE>: PartialEq
[src]

impl<N: Hash, const SIZE: usize> Hash for Multiset<N, SIZE>[src]

impl<N, const SIZE: usize> Mul<Multiset<N, SIZE>> for Multiset<N, SIZE> where
    N: Mul + Copy,
    <N as Mul>::Output: Copy
[src]

type Output = Multiset<<N as Mul>::Output, SIZE>

The resulting type after applying the * operator.

impl<N, const SIZE: usize> MulAssign<Multiset<N, SIZE>> for Multiset<N, SIZE> where
    N: MulAssign + Copy
[src]

impl<N: PartialEq, const SIZE: usize> PartialEq<Multiset<N, SIZE>> for Multiset<N, SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u16; 16]>, SIZE>> for MSu16x16<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u16; 2]>, SIZE>> for MSu16x2<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u16; 32]>, SIZE>> for MSu16x32<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u16; 4]>, SIZE>> for MSu16x4<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u16; 8]>, SIZE>> for MSu16x8<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u32; 16]>, SIZE>> for MSu32x16<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u32; 2]>, SIZE>> for MSu32x2<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u32; 4]>, SIZE>> for MSu32x4<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u32; 8]>, SIZE>> for MSu32x8<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u64; 2]>, SIZE>> for MSu64x2<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u64; 4]>, SIZE>> for MSu64x4<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u64; 8]>, SIZE>> for MSu64x8<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u8; 16]>, SIZE>> for MSu8x16<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u8; 2]>, SIZE>> for MSu8x2<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u8; 32]>, SIZE>> for MSu8x32<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u8; 4]>, SIZE>> for MSu8x4<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u8; 64]>, SIZE>> for MSu8x64<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<Simd<[u8; 8]>, SIZE>> for MSu8x8<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<u16, SIZE>> for MSu16<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<u32, SIZE>> for MSu32<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<u64, SIZE>> for MSu64<SIZE>[src]

impl<const SIZE: usize> PartialOrd<Multiset<u8, SIZE>> for MSu8<SIZE>[src]

impl<N: Send, const SIZE: usize> Send for Multiset<N, SIZE>[src]

impl<N, const SIZE: usize> Sub<Multiset<N, SIZE>> for Multiset<N, SIZE> where
    N: Sub + Copy,
    <N as Sub>::Output: Copy
[src]

type Output = Multiset<<N as Sub>::Output, SIZE>

The resulting type after applying the - operator.

impl<N, const SIZE: usize> SubAssign<Multiset<N, SIZE>> for Multiset<N, SIZE> where
    N: SubAssign + Copy
[src]

impl<N: Sync, const SIZE: usize> Sync for Multiset<N, SIZE>[src]

Auto Trait Implementations

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> Cast<U> for T where
    U: FromCast<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> FromCast<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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