Struct utote::Multiset [−][src]
Multiset! yay
Implementations
impl<N: Copy, U, B> Multiset<N, UInt<U, B>> where
UInt<U, B>: ArrayLength<N>,
[src]
UInt<U, B>: ArrayLength<N>,
pub fn map<N2, F>(&self, mut f: F) -> Multiset<N2, UInt<U, B>> where
N2: Copy,
F: FnMut(N) -> N2,
UInt<U, B>: ArrayLength<N2>,
[src]
N2: Copy,
F: FnMut(N) -> N2,
UInt<U, B>: ArrayLength<N2>,
pub fn fold<Acc, F>(&self, init: Acc, mut f: F) -> Acc where
F: FnMut(Acc, N) -> Acc,
[src]
F: FnMut(Acc, N) -> Acc,
pub fn zip_map<N2, N3, F>(
&self,
other: &Multiset<N2, UInt<U, B>>,
mut f: F
) -> Multiset<N3, UInt<U, B>> where
N2: Copy,
N3: Copy,
F: FnMut(N, N2) -> N3,
UInt<U, B>: ArrayLength<N2> + ArrayLength<N3>,
[src]
&self,
other: &Multiset<N2, UInt<U, B>>,
mut f: F
) -> Multiset<N3, UInt<U, B>> where
N2: Copy,
N3: Copy,
F: FnMut(N, N2) -> N3,
UInt<U, B>: ArrayLength<N2> + ArrayLength<N3>,
impl<U, B> Multiset<u8, U> where
UInt<U, B>: ArrayLength<u8>,
[src]
UInt<U, B>: ArrayLength<u8>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array size with all elements set to zero.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::empty();
pub fn repeat(elem: u8) -> Self
[src]
Returns a Multiset of the given array size with all elements set to elem
.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu8; use typenum::U4; assert_eq!(MSu8::<U4>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu8; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::from_slice(&[0, 2, 3, 0]); let c = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::from_slice(&[0, 2, 3, 0]); let c = MSu8::<U4>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u8
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 4, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu8::<U4>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu8::<U4>::from_slice(&[2, 0, 5, 3]); multiset.choose_random(rng); assert_eq!(multiset.is_singleton(), true);
impl<U, B> Multiset<u16, U> where
UInt<U, B>: ArrayLength<u16>,
[src]
UInt<U, B>: ArrayLength<u16>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array size with all elements set to zero.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::empty();
pub fn repeat(elem: u16) -> Self
[src]
Returns a Multiset of the given array size with all elements set to elem
.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu8; use typenum::U4; assert_eq!(MSu8::<U4>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu8; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::from_slice(&[0, 2, 3, 0]); let c = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::from_slice(&[0, 2, 3, 0]); let c = MSu8::<U4>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u16
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 4, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu8::<U4>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu8::<U4>::from_slice(&[2, 0, 5, 3]); multiset.choose_random(rng); assert_eq!(multiset.is_singleton(), true);
impl<U, B> Multiset<u32, U> where
UInt<U, B>: ArrayLength<u32>,
[src]
UInt<U, B>: ArrayLength<u32>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array size with all elements set to zero.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::empty();
pub fn repeat(elem: u32) -> Self
[src]
Returns a Multiset of the given array size with all elements set to elem
.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu8; use typenum::U4; assert_eq!(MSu8::<U4>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu8; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::from_slice(&[0, 2, 3, 0]); let c = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::from_slice(&[0, 2, 3, 0]); let c = MSu8::<U4>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 4, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu8::<U4>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu8::<U4>::from_slice(&[2, 0, 5, 3]); multiset.choose_random(rng); assert_eq!(multiset.is_singleton(), true);
impl<U, B> Multiset<u64, U> where
UInt<U, B>: ArrayLength<u64>,
[src]
UInt<U, B>: ArrayLength<u64>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array size with all elements set to zero.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::empty();
pub fn repeat(elem: u64) -> Self
[src]
Returns a Multiset of the given array size with all elements set to elem
.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu8; use typenum::U4; assert_eq!(MSu8::<U4>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu8; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::from_slice(&[0, 2, 3, 0]); let c = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::from_slice(&[0, 2, 3, 0]); let c = MSu8::<U4>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u64
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 4, 0]); let b = MSu8::<U4>::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; use typenum::U4; let a = MSu8::<U4>::from_slice(&[1, 2, 0, 0]); let b = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let mut multiset = MSu8::<U4>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu8::<U4>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu8::<U4>::from_slice(&[2, 0, 5, 3]); multiset.choose_random(rng); assert_eq!(multiset.is_singleton(), true);
impl<U, B> Multiset<u8, U> where
UInt<U, B>: ArrayLength<u8>,
f64: From<u8>,
[src]
UInt<U, B>: ArrayLength<u8>,
f64: From<u8>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[2, 1, 1, 0]); let result = multiset.shannon_entropy(); // approximate: result == 1.0397207708399179
impl<U, B> Multiset<u16, U> where
UInt<U, B>: ArrayLength<u16>,
f64: From<u16>,
[src]
UInt<U, B>: ArrayLength<u16>,
f64: From<u16>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[2, 1, 1, 0]); let result = multiset.shannon_entropy(); // approximate: result == 1.0397207708399179
impl<U, B> Multiset<u32, U> where
UInt<U, B>: ArrayLength<u32>,
f64: From<u32>,
[src]
UInt<U, B>: ArrayLength<u32>,
f64: From<u32>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu8; use typenum::U4; let multiset = MSu8::<U4>::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; use typenum::U4; let multiset = MSu8::<U4>::from_slice(&[2, 1, 1, 0]); let result = multiset.shannon_entropy(); // approximate: result == 1.0397207708399179
impl<U, B> Multiset<Simd<[u8; 2]>, U> where
UInt<U, B>: ArrayLength<u8x2>,
[src]
UInt<U, B>: ArrayLength<u8x2>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u8; 4]>, U> where
UInt<U, B>: ArrayLength<u8x4>,
[src]
UInt<U, B>: ArrayLength<u8x4>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u8; 8]>, U> where
UInt<U, B>: ArrayLength<u8x8>,
[src]
UInt<U, B>: ArrayLength<u8x8>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u8; 16]>, U> where
UInt<U, B>: ArrayLength<u8x16>,
[src]
UInt<U, B>: ArrayLength<u8x16>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u8; 32]>, U> where
UInt<U, B>: ArrayLength<u8x32>,
[src]
UInt<U, B>: ArrayLength<u8x32>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u8; 64]>, U> where
UInt<U, B>: ArrayLength<u8x64>,
[src]
UInt<U, B>: ArrayLength<u8x64>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u16; 2]>, U> where
UInt<U, B>: ArrayLength<u16x2>,
[src]
UInt<U, B>: ArrayLength<u16x2>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u16; 4]>, U> where
UInt<U, B>: ArrayLength<u16x4>,
[src]
UInt<U, B>: ArrayLength<u16x4>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u16; 8]>, U> where
UInt<U, B>: ArrayLength<u16x8>,
[src]
UInt<U, B>: ArrayLength<u16x8>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u16; 16]>, U> where
UInt<U, B>: ArrayLength<u16x16>,
[src]
UInt<U, B>: ArrayLength<u16x16>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u16; 32]>, U> where
UInt<U, B>: ArrayLength<u16x32>,
[src]
UInt<U, B>: ArrayLength<u16x32>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u32; 2]>, U> where
UInt<U, B>: ArrayLength<u32x2>,
[src]
UInt<U, B>: ArrayLength<u32x2>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u32; 4]>, U> where
UInt<U, B>: ArrayLength<u32x4>,
[src]
UInt<U, B>: ArrayLength<u32x4>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u32; 8]>, U> where
UInt<U, B>: ArrayLength<u32x8>,
[src]
UInt<U, B>: ArrayLength<u32x8>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u32; 16]>, U> where
UInt<U, B>: ArrayLength<u32x16>,
[src]
UInt<U, B>: ArrayLength<u32x16>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u64; 2]>, U> where
UInt<U, B>: ArrayLength<u64x2>,
[src]
UInt<U, B>: ArrayLength<u64x2>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u64; 4]>, U> where
UInt<U, B>: ArrayLength<u64x4>,
[src]
UInt<U, B>: ArrayLength<u64x4>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u64; 8]>, U> where
UInt<U, B>: ArrayLength<u64x8>,
[src]
UInt<U, B>: ArrayLength<u64x8>,
pub fn empty() -> Self
[src]
Returns a Multiset of the given array * SIMD vector size with all elements set to zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::empty();
pub 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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MSu32x2; use typenum::U2; assert_eq!(MSu32x2::<U2>::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MSu32x2; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::from_slice(&[0, 2, 3, 0]); let c = MSu32x2::<U2>::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 4, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let a = MSu32x2::<U2>::from_slice(&[1, 2, 0, 0]); let b = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let mut multiset = MSu32x2::<U2>::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MSu32x2::<U2>::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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 typenum::U2; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u8; 2]>, U> where
UInt<U, B>: ArrayLength<u8x2>,
f64: From<u8>,
f64x2: From<u8x2>,
[src]
UInt<U, B>: ArrayLength<u8x2>,
f64: From<u8>,
f64x2: From<u8x2>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u8; 4]>, U> where
UInt<U, B>: ArrayLength<u8x4>,
f64: From<u8>,
f64x4: From<u8x4>,
[src]
UInt<U, B>: ArrayLength<u8x4>,
f64: From<u8>,
f64x4: From<u8x4>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u8; 8]>, U> where
UInt<U, B>: ArrayLength<u8x8>,
f64: From<u8>,
f64x8: From<u8x8>,
[src]
UInt<U, B>: ArrayLength<u8x8>,
f64: From<u8>,
f64x8: From<u8x8>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u16; 2]>, U> where
UInt<U, B>: ArrayLength<u16x2>,
f64: From<u16>,
f64x2: From<u16x2>,
[src]
UInt<U, B>: ArrayLength<u16x2>,
f64: From<u16>,
f64x2: From<u16x2>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u16; 4]>, U> where
UInt<U, B>: ArrayLength<u16x4>,
f64: From<u16>,
f64x4: From<u16x4>,
[src]
UInt<U, B>: ArrayLength<u16x4>,
f64: From<u16>,
f64x4: From<u16x4>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u16; 8]>, U> where
UInt<U, B>: ArrayLength<u16x8>,
f64: From<u16>,
f64x8: From<u16x8>,
[src]
UInt<U, B>: ArrayLength<u16x8>,
f64: From<u16>,
f64x8: From<u16x8>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u32; 2]>, U> where
UInt<U, B>: ArrayLength<u32x2>,
f64: From<u32>,
f64x2: From<u32x2>,
[src]
UInt<U, B>: ArrayLength<u32x2>,
f64: From<u32>,
f64x2: From<u32x2>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u32; 4]>, U> where
UInt<U, B>: ArrayLength<u32x4>,
f64: From<u32>,
f64x4: From<u32x4>,
[src]
UInt<U, B>: ArrayLength<u32x4>,
f64: From<u32>,
f64x4: From<u32x4>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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<U, B> Multiset<Simd<[u32; 8]>, U> where
UInt<U, B>: ArrayLength<u32x8>,
f64: From<u32>,
f64x8: From<u32x8>,
[src]
UInt<U, B>: ArrayLength<u32x8>,
f64: From<u32>,
f64x8: From<u32x8>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MSu32x2; use typenum::U2; let multiset = MSu32x2::<U2>::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; use typenum::U2; let multiset = MSu32x2::<U2>::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 Multiset<Simd<[u8; 2]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u8) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u8]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u8)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u8>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u8
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u8)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u8
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u8; 4]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u8) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u8]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u8)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u8>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u8
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u8)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u8
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u8; 8]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u8) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u8]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u8)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u8>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u8
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u8)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u8
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u8; 16]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u8) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u8]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u8)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u8>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u8
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u8)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u8
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u8; 32]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u8) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u8]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u8)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u8>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u8
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u8)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u8
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u8; 64]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u8) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u8]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u8)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u8>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u8
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u8)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u8
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u16; 2]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u16) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u16]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u16)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u16>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u16
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u16)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u16
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u16; 4]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u16) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u16]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u16)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u16>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u16
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u16)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u16
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u16; 8]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u16) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u16]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u16)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u16>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u16
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u16)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u16
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u16; 16]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u16) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u16]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u16)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u16>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u16
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u16)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u16
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u16; 32]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u16) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u16]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u16)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u16>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u16
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u16)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u16
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u32; 2]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u32) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u32]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u32)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u32>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u32
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u32)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u32
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u32; 4]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u32) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u32]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u32)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u32>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u32
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u32)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u32
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u32; 8]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u32) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u32]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u32)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u32>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u32
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u32)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u32
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u32; 16]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u32) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u32]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u32)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u32>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u32
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u32)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u32
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u64; 2]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u64) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u64]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u64)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u64>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u64
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u64)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u64
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u64; 4]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u64) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u64]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u64)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u64>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u64
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u64)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u64
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u64; 8]>, UTerm>
[src]
pub const fn empty() -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::empty();
pub const fn repeat(elem: u64) -> Self
[src]
Returns a Multiset of the given SIMD vector size with all elements set to elem
.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::repeat(5);
pub fn from_slice(slice: &[u64]) -> Self
[src]
Returns a Multiset from a slice of the given SIMD vector size.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[1, 2, 3, 4]);
pub const fn len() -> usize
[src]
The number of elements in the multiset.
Examples
use utote::MS0u16x4; assert_eq!(MS0u16x4::len(), 4);
pub fn clear(&mut self)
[src]
Sets all element counts in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
pub fn insert(&mut self, elem: usize, amount: u64)
[src]
Set the counter of an element in the multiset to amount
.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn remove(&mut self, elem: usize)
[src]
Set the counter of an element in the multiset to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::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::MS0u16x4; let mut multiset = MS0u16x4::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 SIMD vector.
pub fn get(self, elem: usize) -> Option<u64>
[src]
Returns the amount of an element in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 SIMD vector.
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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::from_slice(&[0, 2, 3, 0]); let c = MS0u16x4::from_slice(&[1, 2, 3, 0]); assert_eq!(a.intersection(&b), c);
pub fn count_zero(&self) -> u32
[src]
Return the number of elements whose counter is zero.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[0, 0, 0, 0]); assert_eq!(multiset.is_empty(), true); assert_eq!(MS0u16x4::empty().is_empty(), true);
pub fn is_singleton(&self) -> bool
[src]
Check whether only one element has a non-zero count.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 4, 0]); let b = MS0u16x4::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::MS0u16x4; let a = MS0u16x4::from_slice(&[1, 2, 0, 0]); let b = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmax(), (2, 5));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imax(&self) -> usize
[src]
Returns the element with the largest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imax(), 2);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn max(&self) -> u64
[src]
Returns the largest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.max(), 5);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn argmin(&self) -> (usize, u64)
[src]
Returns a tuple containing the (element, corresponding smallest counter) in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.argmin(), (1, 0));
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn imin(&self) -> usize
[src]
Returns the element with the smallest count in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.imin(), 1);
Notes:
- The implementation extracts values from the underlying SIMD vector.
pub fn min(&self) -> u64
[src]
Returns the smallest counter in the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); assert_eq!(multiset.min(), 0);
Notes:
- The implementation uses a horizontal operation on the underlying SIMD vector.
pub fn choose(&mut self, elem: usize)
[src]
Set all element counts, except for the given elem
, to zero.
Examples
use utote::MS0u16x4; let mut multiset = MS0u16x4::from_slice(&[2, 0, 5, 3]); multiset.choose(2); let result = MS0u16x4::from_slice(&[0, 0, 5, 0]); assert_eq!(multiset, result);
pub fn choose_random(&mut self, rng: &mut StdRng)
[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::MS0u16x4; use rand::prelude::*; let rng = &mut StdRng::seed_from_u64(thread_rng().next_u64()); let mut multiset = MS0u16x4::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 vector.
impl Multiset<Simd<[u8; 2]>, UTerm> where
f64: From<u8>,
f64x2: From<u8x2>,
[src]
f64: From<u8>,
f64x2: From<u8x2>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 Multiset<Simd<[u8; 4]>, UTerm> where
f64: From<u8>,
f64x4: From<u8x4>,
[src]
f64: From<u8>,
f64x4: From<u8x4>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 Multiset<Simd<[u8; 8]>, UTerm> where
f64: From<u8>,
f64x8: From<u8x8>,
[src]
f64: From<u8>,
f64x8: From<u8x8>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 Multiset<Simd<[u16; 2]>, UTerm> where
f64: From<u16>,
f64x2: From<u16x2>,
[src]
f64: From<u16>,
f64x2: From<u16x2>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 Multiset<Simd<[u16; 4]>, UTerm> where
f64: From<u16>,
f64x4: From<u16x4>,
[src]
f64: From<u16>,
f64x4: From<u16x4>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 Multiset<Simd<[u16; 8]>, UTerm> where
f64: From<u16>,
f64x8: From<u16x8>,
[src]
f64: From<u16>,
f64x8: From<u16x8>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 Multiset<Simd<[u32; 2]>, UTerm> where
f64: From<u32>,
f64x2: From<u32x2>,
[src]
f64: From<u32>,
f64x2: From<u32x2>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 Multiset<Simd<[u32; 4]>, UTerm> where
f64: From<u32>,
f64x4: From<u32x4>,
[src]
f64: From<u32>,
f64x4: From<u32x4>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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 Multiset<Simd<[u32; 8]>, UTerm> where
f64: From<u32>,
f64x8: From<u32x8>,
[src]
f64: From<u32>,
f64x8: From<u32x8>,
pub fn collision_entropy(&self) -> f64
[src]
Calculate the collision entropy of the multiset.
Examples
use utote::MS0u16x4; let multiset = MS0u16x4::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::MS0u16x4; let multiset = MS0u16x4::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, U, B> AddAssign<Multiset<N, UInt<U, B>>> for Multiset<N, UInt<U, B>> where
N: AddAssign + Copy,
UInt<U, B>: ArrayLength<N>,
[src]
N: AddAssign + Copy,
UInt<U, B>: ArrayLength<N>,
fn add_assign(&mut self, rhs: Self)
[src]
impl<N> AddAssign<Multiset<N, UTerm>> for Multiset<N, U0> where
N: AddAssign,
[src]
N: AddAssign,
fn add_assign(&mut self, rhs: Self)
[src]
impl<N: Clone, U: Clone + MultisetStorage<N>> Clone for Multiset<N, U> where
U::Storage: Clone,
[src]
U::Storage: Clone,
impl<N: Copy, U: Copy + MultisetStorage<N>> Copy for Multiset<N, U> where
U::Storage: Copy,
[src]
U::Storage: Copy,
impl<N: Debug, U: Debug + MultisetStorage<N>> Debug for Multiset<N, U> where
U::Storage: Debug,
[src]
U::Storage: Debug,
impl<N, U, B> DivAssign<Multiset<N, UInt<U, B>>> for Multiset<N, UInt<U, B>> where
N: DivAssign + Copy,
UInt<U, B>: ArrayLength<N>,
[src]
N: DivAssign + Copy,
UInt<U, B>: ArrayLength<N>,
fn div_assign(&mut self, rhs: Self)
[src]
impl<N> DivAssign<Multiset<N, UTerm>> for Multiset<N, U0> where
N: DivAssign,
[src]
N: DivAssign,
fn div_assign(&mut self, rhs: Self)
[src]
impl<N, U: MultisetStorage<N>> Eq for Multiset<N, U> where
Multiset<N, U>: PartialEq,
[src]
Multiset<N, U>: PartialEq,
impl<N: Hash, U: Hash + MultisetStorage<N>> Hash for Multiset<N, U> where
U::Storage: Hash,
[src]
U::Storage: Hash,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<N, U, B> MulAssign<Multiset<N, UInt<U, B>>> for Multiset<N, UInt<U, B>> where
N: MulAssign + Copy,
UInt<U, B>: ArrayLength<N>,
[src]
N: MulAssign + Copy,
UInt<U, B>: ArrayLength<N>,
fn mul_assign(&mut self, rhs: Self)
[src]
impl<N> MulAssign<Multiset<N, UTerm>> for Multiset<N, U0> where
N: MulAssign,
[src]
N: MulAssign,
fn mul_assign(&mut self, rhs: Self)
[src]
impl<N, U: MultisetStorage<N>> PartialEq<Multiset<N, U>> for Multiset<N, U> where
<U as MultisetStorage<N>>::Storage: PartialEq,
[src]
<U as MultisetStorage<N>>::Storage: PartialEq,
impl<U, B> PartialOrd<Multiset<Simd<[u16; 16]>, UInt<U, B>>> for MSu16x16<UInt<U, B>> where
UInt<U, B>: ArrayLength<u16x16>,
[src]
UInt<U, B>: ArrayLength<u16x16>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u16; 16]>, UTerm>> for MS0u16x16
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u16; 2]>, UInt<U, B>>> for MSu16x2<UInt<U, B>> where
UInt<U, B>: ArrayLength<u16x2>,
[src]
UInt<U, B>: ArrayLength<u16x2>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u16; 2]>, UTerm>> for MS0u16x2
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u16; 32]>, UInt<U, B>>> for MSu16x32<UInt<U, B>> where
UInt<U, B>: ArrayLength<u16x32>,
[src]
UInt<U, B>: ArrayLength<u16x32>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u16; 32]>, UTerm>> for MS0u16x32
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u16; 4]>, UInt<U, B>>> for MSu16x4<UInt<U, B>> where
UInt<U, B>: ArrayLength<u16x4>,
[src]
UInt<U, B>: ArrayLength<u16x4>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u16; 4]>, UTerm>> for MS0u16x4
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u16; 8]>, UInt<U, B>>> for MSu16x8<UInt<U, B>> where
UInt<U, B>: ArrayLength<u16x8>,
[src]
UInt<U, B>: ArrayLength<u16x8>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u16; 8]>, UTerm>> for MS0u16x8
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u32; 16]>, UInt<U, B>>> for MSu32x16<UInt<U, B>> where
UInt<U, B>: ArrayLength<u32x16>,
[src]
UInt<U, B>: ArrayLength<u32x16>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u32; 16]>, UTerm>> for MS0u32x16
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u32; 2]>, UInt<U, B>>> for MSu32x2<UInt<U, B>> where
UInt<U, B>: ArrayLength<u32x2>,
[src]
UInt<U, B>: ArrayLength<u32x2>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u32; 2]>, UTerm>> for MS0u32x2
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u32; 4]>, UInt<U, B>>> for MSu32x4<UInt<U, B>> where
UInt<U, B>: ArrayLength<u32x4>,
[src]
UInt<U, B>: ArrayLength<u32x4>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u32; 4]>, UTerm>> for MS0u32x4
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u32; 8]>, UInt<U, B>>> for MSu32x8<UInt<U, B>> where
UInt<U, B>: ArrayLength<u32x8>,
[src]
UInt<U, B>: ArrayLength<u32x8>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u32; 8]>, UTerm>> for MS0u32x8
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u64; 2]>, UInt<U, B>>> for MSu64x2<UInt<U, B>> where
UInt<U, B>: ArrayLength<u64x2>,
[src]
UInt<U, B>: ArrayLength<u64x2>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u64; 2]>, UTerm>> for MS0u64x2
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u64; 4]>, UInt<U, B>>> for MSu64x4<UInt<U, B>> where
UInt<U, B>: ArrayLength<u64x4>,
[src]
UInt<U, B>: ArrayLength<u64x4>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u64; 4]>, UTerm>> for MS0u64x4
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u64; 8]>, UInt<U, B>>> for MSu64x8<UInt<U, B>> where
UInt<U, B>: ArrayLength<u64x8>,
[src]
UInt<U, B>: ArrayLength<u64x8>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u64; 8]>, UTerm>> for MS0u64x8
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u8; 16]>, UInt<U, B>>> for MSu8x16<UInt<U, B>> where
UInt<U, B>: ArrayLength<u8x16>,
[src]
UInt<U, B>: ArrayLength<u8x16>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u8; 16]>, UTerm>> for MS0u8x16
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u8; 2]>, UInt<U, B>>> for MSu8x2<UInt<U, B>> where
UInt<U, B>: ArrayLength<u8x2>,
[src]
UInt<U, B>: ArrayLength<u8x2>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u8; 2]>, UTerm>> for MS0u8x2
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u8; 32]>, UInt<U, B>>> for MSu8x32<UInt<U, B>> where
UInt<U, B>: ArrayLength<u8x32>,
[src]
UInt<U, B>: ArrayLength<u8x32>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u8; 32]>, UTerm>> for MS0u8x32
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u8; 4]>, UInt<U, B>>> for MSu8x4<UInt<U, B>> where
UInt<U, B>: ArrayLength<u8x4>,
[src]
UInt<U, B>: ArrayLength<u8x4>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u8; 4]>, UTerm>> for MS0u8x4
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u8; 64]>, UInt<U, B>>> for MSu8x64<UInt<U, B>> where
UInt<U, B>: ArrayLength<u8x64>,
[src]
UInt<U, B>: ArrayLength<u8x64>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u8; 64]>, UTerm>> for MS0u8x64
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<Simd<[u8; 8]>, UInt<U, B>>> for MSu8x8<UInt<U, B>> where
UInt<U, B>: ArrayLength<u8x8>,
[src]
UInt<U, B>: ArrayLength<u8x8>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl PartialOrd<Multiset<Simd<[u8; 8]>, UTerm>> for MS0u8x8
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<u16, UInt<U, B>>> for MSu16<UInt<U, B>> where
UInt<U, B>: ArrayLength<u16>,
[src]
UInt<U, B>: ArrayLength<u16>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<u32, UInt<U, B>>> for MSu32<UInt<U, B>> where
UInt<U, B>: ArrayLength<u32>,
[src]
UInt<U, B>: ArrayLength<u32>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<u64, UInt<U, B>>> for MSu64<UInt<U, B>> where
UInt<U, B>: ArrayLength<u64>,
[src]
UInt<U, B>: ArrayLength<u64>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<U, B> PartialOrd<Multiset<u8, UInt<U, B>>> for MSu8<UInt<U, B>> where
UInt<U, B>: ArrayLength<u8>,
[src]
UInt<U, B>: ArrayLength<u8>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<N, U, B> SubAssign<Multiset<N, UInt<U, B>>> for Multiset<N, UInt<U, B>> where
N: SubAssign + Copy,
UInt<U, B>: ArrayLength<N>,
[src]
N: SubAssign + Copy,
UInt<U, B>: ArrayLength<N>,
fn sub_assign(&mut self, rhs: Self)
[src]
impl<N> SubAssign<Multiset<N, UTerm>> for Multiset<N, U0> where
N: SubAssign,
[src]
N: SubAssign,
fn sub_assign(&mut self, rhs: Self)
[src]
Auto Trait Implementations
impl<N, U> RefUnwindSafe for Multiset<N, U> where
<U as MultisetStorage<N>>::Storage: RefUnwindSafe,
[src]
<U as MultisetStorage<N>>::Storage: RefUnwindSafe,
impl<N, U> Send for Multiset<N, U> where
<U as MultisetStorage<N>>::Storage: Send,
[src]
<U as MultisetStorage<N>>::Storage: Send,
impl<N, U> Sync for Multiset<N, U> where
<U as MultisetStorage<N>>::Storage: Sync,
[src]
<U as MultisetStorage<N>>::Storage: Sync,
impl<N, U> Unpin for Multiset<N, U> where
<U as MultisetStorage<N>>::Storage: Unpin,
[src]
<U as MultisetStorage<N>>::Storage: Unpin,
impl<N, U> UnwindSafe for Multiset<N, U> where
<U as MultisetStorage<N>>::Storage: UnwindSafe,
[src]
<U as MultisetStorage<N>>::Storage: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> Cast<U> for T where
U: FromCast<T>,
[src]
U: FromCast<T>,
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]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,