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 fn bits_32_63(&self) -> u32
pub fn bits_32_63(&self) -> u32
Returns bits 32 to 63.
Sourcepub fn bits_64_95(&self) -> u32
pub fn bits_64_95(&self) -> u32
Returns bits 64 to 95.
Sourcepub fn bits_96_127(&self) -> u32
pub fn bits_96_127(&self) -> u32
Returns bits 96 to 127.
Sourcepub fn bits_64_127(&self) -> u64
pub fn bits_64_127(&self) -> u64
Returns bits 64 to 127.
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, other: Self)
fn bitand_assign(&mut self, other: Self)
&= operation. Read moreSource§impl BitOrAssign for BitSet128
impl BitOrAssign for BitSet128
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
|= operation. Read moreSource§impl BitXorAssign for BitSet128
impl BitXorAssign for BitSet128
Source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
^= operation. Read moreimpl Copy for BitSet128
Source§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>,
impl Eq for BitSet128
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.
Source§impl Ord for BitSet128
impl Ord for BitSet128
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for BitSet128
impl PartialOrd for BitSet128
impl PostcardValue<'_> for BitSet128
serde only.