Skip to main content

BitSet128

Struct BitSet128 

Source
pub struct BitSet128(/* private fields */);
Expand description

A memory-efficient 128-bit set for embedded environments.

Implementations§

Source§

impl BitSet128

Source

pub const fn new() -> Self

Create a new empty bitset.

Source§

impl BitSet128

Source

pub fn reset_all(&mut self)

Resets all bits to 0.

Source

pub fn reset(&mut self, index: u8)

Resets the bit at index to 0. Does nothing if the index is out of bounds.

Source

pub fn set_all(&mut self)

Sets all bits to 1.

Source

pub fn set(&mut self, index: u8)

Sets the bit at index to 1. Does nothing if the index is out of bounds.

Source

pub fn flip(&mut self, index: u8)

Flips the bit at index. Does nothing if the index is out of bounds.

Source

pub fn flip_all(&mut self)

Flips all bits in the bitset (0s become 1s, and 1s become 0s).

Source

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.

Source

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.

Source

pub const fn count_ones(&self) -> u32

Returns the number of set bits (population count).

Source

pub const fn leading_zeros(&self) -> u32

Returns the number of leading zeros in the bitset, counting from the most significant bit (index 127).

Source

pub const fn is_empty(&self) -> bool

Returns true if no bits are set.

Source

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.

Source

pub const fn is_superset(&self, other: &Self) -> bool

Returns true if this bitset contains all the bits set in other.

Source

pub const fn is_subset(&self, other: &BitSet128) -> bool

Returns true if this bitset is a subset of other.

Source

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.

Source

pub fn iter(&self) -> BitSet128Iter

Returns an iterator over the indices of the set bits.

Trait Implementations§

Source§

impl Binary for BitSet128

Source§

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

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

impl BitAnd for BitSet128

Source§

type Output = BitSet128

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for BitSet128

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for BitSet128

Source§

type Output = BitSet128

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign for BitSet128

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for BitSet128

Source§

type Output = BitSet128

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign for BitSet128

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for BitSet128

Source§

fn clone(&self) -> BitSet128

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BitSet128

Source§

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

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

impl Default for BitSet128

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for BitSet128

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 Extend<u8> for BitSet128

Source§

fn extend<I: IntoIterator<Item = u8>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<(u32, u32)> for BitSet128

BitSet128 from (u32, u32).

Source§

fn from((a, b): (u32, u32)) -> Self

Converts to this type from the input type.
Source§

impl From<(u32, u32, u32, u32)> for BitSet128

BitSet128 from (u32, u32, u32, u32).

Source§

fn from((a, b, c, d): (u32, u32, u32, u32)) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for BitSet128

BitSet128 from u32.

Source§

fn from(a: u32) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<u8> for BitSet128

From iterator for bitset.

Source§

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

Creates a value from an iterator. Read more
Source§

impl Index<u8> for BitSet128

Source§

type Output = bool

The returned type after indexing.
Source§

fn index(&self, index: u8) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<usize> for BitSet128

Source§

type Output = bool

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IntoIterator for &BitSet128

Non-consuming iterator for bitset reference.

Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = BitSet128Iter

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 IntoIterator for BitSet128

Non-consuming iterator for bitset.

Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = BitSet128Iter

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 Ord for BitSet128

Source§

fn cmp(&self, other: &BitSet128) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for BitSet128

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 PartialOrd for BitSet128

Source§

fn partial_cmp(&self, other: &BitSet128) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for BitSet128

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 UpperHex for BitSet128

Source§

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

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

impl Copy for BitSet128

Source§

impl Eq for BitSet128

Source§

impl StructuralPartialEq for BitSet128

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>,