pub struct BitSet128(/* private fields */);Expand description
A memory-efficient 128-bit set for embedded environments.
Implementations§
Source§impl BitSet128
impl BitSet128
Sourcepub fn reset(&mut self, index: u8)
pub fn reset(&mut self, index: u8)
Resets the bit at index to 0. Does nothing if the index is out of bounds.
Sourcepub fn set(&mut self, index: u8)
pub fn set(&mut self, index: u8)
Sets the bit at index to 1. Does nothing if the index is out of bounds.
Sourcepub fn flip(&mut self, index: u8)
pub fn flip(&mut self, index: u8)
Flips the bit at index. Does nothing if the index is out of bounds.
Sourcepub fn and_not(&mut self, other: Self)
pub fn and_not(&mut self, other: Self)
In-place Difference / Mask-Clear. Clears any bits that are set in other.
This represents the mathematical operation: self = self AND NOT other.
Sourcepub fn test(&self, index: u8) -> bool
pub fn test(&self, index: u8) -> bool
Tests if the bit at index is 1.
Returns false if the bit is 0 or index is out of bounds.
Sourcepub const fn count_ones(&self) -> u32
pub const fn count_ones(&self) -> u32
Returns the number of set bits (population count).
Sourcepub const fn leading_zeros(&self) -> u32
pub const fn leading_zeros(&self) -> u32
Returns the number of leading zeros in the bitset, counting from the most significant bit (index 127).
Sourcepub const fn last_set(&self) -> Option<u8>
pub const fn last_set(&self) -> Option<u8>
Returns the highest index set, or None if the bitset is empty. Useful for finding the “top” of a priority queue or resource map.
Sourcepub const fn is_superset(&self, other: &Self) -> bool
pub const fn is_superset(&self, other: &Self) -> bool
Returns true if this bitset contains all the bits set in other.
Sourcepub const fn is_subset(&self, other: &BitSet128) -> bool
pub const fn is_subset(&self, other: &BitSet128) -> bool
Returns true if this bitset is a subset of other.
Sourcepub const fn intersects(&self, other: &Self) -> bool
pub const fn intersects(&self, other: &Self) -> bool
Returns true if this bitset shares at least one common set bit with other.
Returns false if there is no overlap or if either bitset is empty.
Sourcepub fn iter(&self) -> BitSet128Iter ⓘ
pub fn iter(&self) -> BitSet128Iter ⓘ
Returns an iterator over the indices of the set bits.
Trait Implementations§
Source§impl BitAndAssign for BitSet128
impl BitAndAssign for BitSet128
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOrAssign for BitSet128
impl BitOrAssign for BitSet128
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitXorAssign for BitSet128
impl BitXorAssign for BitSet128
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl<'de> Deserialize<'de> for BitSet128
impl<'de> Deserialize<'de> for BitSet128
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Extend<u8> for BitSet128
impl Extend<u8> for BitSet128
Source§fn extend<I: IntoIterator<Item = u8>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = u8>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<u8> for BitSet128
From iterator for bitset.
impl FromIterator<u8> for BitSet128
From iterator for bitset.
Source§impl IntoIterator for &BitSet128
Non-consuming iterator for bitset reference.
impl IntoIterator for &BitSet128
Non-consuming iterator for bitset reference.
Source§impl IntoIterator for BitSet128
Non-consuming iterator for bitset.
impl IntoIterator for BitSet128
Non-consuming iterator for bitset.