Type Definition utote::MS0u8x8[][src]

type MS0u8x8 = Multiset<u8x8, UTerm>;

Implementations

impl MS0u8x8[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.union(&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<T: RngCore>(&mut self, rng: &mut T)[src]

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

Examples

use utote::MS0u16x4;
use rand::prelude::*;
let rng = &mut SmallRng::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 MS0u8x8 where
    f64: From<u8>,
    f64x8: From<u8x8>, 
[src]

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

Calculate the collision entropy of the multiset.

Examples

use utote::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<'a> FromIterator<&'a u8> for MS0u8x8[src]

impl FromIterator<u8> for MS0u8x8[src]

impl IntoIterator for MS0u8x8[src]

type Item = u8

The type of the elements being iterated over.

type IntoIter = MultisetIterator<u8x8, U0>

Which kind of iterator are we turning this into?

impl PartialOrd<Multiset<Simd<[u8; 8]>, UTerm>> for MS0u8x8[src]