pub struct LilBitSet { /* private fields */ }
Expand description
Set-like data structure for storing u8 elements. Cannot contains values >= 64.
Implementations§
Source§impl LilBitSet
impl LilBitSet
Sourcepub fn largest_allowed() -> u8
pub fn largest_allowed() -> u8
Returns the largest u8 values that IS permitted to be inserted.
Sourcepub fn new_from_raw(raw: u64) -> Self
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}.
Sourcepub fn get(&self, element: u8) -> Option<u8>
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().
Sourcepub fn universe() -> LilBitSet
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
Sourcepub fn insert(&mut self, element: u8) -> bool
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().
Sourcepub fn remove(&mut self, element: u8) -> bool
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().
Sourcepub fn union(&self, other: &Self) -> Self
pub fn union(&self, other: &Self) -> Self
Returns the set union of this, and the given LilBitSet
.
Sourcepub fn itersection(&self, other: &Self) -> Self
pub fn itersection(&self, other: &Self) -> Self
Returns the set itersection of this, and the given LilBitSet
.
Sourcepub fn symmetric_difference(&self, other: &Self) -> Self
pub fn symmetric_difference(&self, other: &Self) -> Self
Returns the set symmetric difference of this, and the given LilBitSet
.
Sourcepub fn complement(&self) -> LilBitSet
pub fn complement(&self) -> LilBitSet
Relying on Self::universe()
, this function can be useful in reasoning
over missing elements in a more convenient way