Struct LilBitSet

Source
pub struct LilBitSet { /* private fields */ }
Expand description

Set-like data structure for storing u8 elements. Cannot contains values >= 64.

Implementations§

Source§

impl LilBitSet

Source

pub fn new() -> LilBitSet

Creates a new, empty LilBitSet.

Source

pub fn largest_allowed() -> u8

Returns the largest u8 values that IS permitted to be inserted.

Source

pub fn new_from_raw(raw: u64) -> Self

Constructs a LilBitSet from a u64. The indices of positive bits refers to the presence of a u8 in the set. ie ‘…1010’ binary for 10 will represent the set {1,3}.

Source

pub fn into_raw(self) -> u64

Inverse of new_from_raw

Source

pub fn get(&self, element: u8) -> Option<u8>

Included only as it is a common function for the HashSet. Here it simply wraps contains.

§Panics

panics when element > Self::largest_allowed().

Source

pub fn contains(&self, element: u8) -> bool

Returns true IFF the given u8 is in the set.

§Panics

panics when element > Self::largest_allowed().

Source

pub fn is_empty(&self) -> bool

Returns true IFF the set is empty (contains no values).

Source

pub fn universe() -> LilBitSet

Of course this set is not unqiue in its finite value-space for set elements. However, as there is the additional restriction of x <= Self::largest_allowed() for any element x, the UNIVERSE of missing elements can be useful

Source

pub fn insert(&mut self, element: u8) -> bool

Attempts to insert the given u8 into the set. Returns true IFF successful.

§Panics

panics when element > Self::largest_allowed().

Source

pub fn remove(&mut self, element: u8) -> bool

Attempts to remove a given u8 from the set. Returns true IFF successful.

§Panics

panics when element >= Self::largest_allowed().

Source

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

Returns the set union of this, and the given LilBitSet.

Source

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

Returns the set itersection of this, and the given LilBitSet.

Source

pub fn len(&self) -> usize

Returns the set cardinality (number of elements of the set).

Source

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

Returns the set symmetric difference of this, and the given LilBitSet.

Source

pub fn complement(&self) -> LilBitSet

Relying on Self::universe(), this function can be useful in reasoning over missing elements in a more convenient way

Trait Implementations§

Source§

impl Clone for LilBitSet

Source§

fn clone(&self) -> LilBitSet

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LilBitSet

Source§

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

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

impl<'de> Deserialize<'de> for LilBitSet

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> FromIterator<&'a u8> for LilBitSet

Source§

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

Creates a value from an iterator. Read more
Source§

impl FromIterator<u8> for LilBitSet

Source§

fn from_iter<I: IntoIterator<Item = u8>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Into<BTreeSet<u8>> for LilBitSet

Source§

fn into(self) -> BTreeSet<u8>

Converts this type into the (usually inferred) input type.
Source§

impl Into<HashSet<u8>> for LilBitSet

Source§

fn into(self) -> HashSet<u8>

Converts this type into the (usually inferred) input type.
Source§

impl Into<LilBitSet> for BTreeSet<u8>

Source§

fn into(self) -> LilBitSet

Converts this type into the (usually inferred) input type.
Source§

impl Into<LilBitSet> for HashSet<u8>

Source§

fn into(self) -> LilBitSet

Converts this type into the (usually inferred) input type.
Source§

impl IntoIterator for LilBitSet

Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for LilBitSet

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for LilBitSet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for LilBitSet

Source§

impl Eq for LilBitSet

Source§

impl StructuralPartialEq for LilBitSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,