Skip to main content

BitMask

Struct BitMask 

Source
pub struct BitMask {
    pub bits: Vec<u32>,
    pub len: usize,
    pub count: usize,
}

Fields§

§bits: Vec<u32>§len: usize§count: usize

Implementations§

Source§

impl BitMask

Source

pub fn new(len: usize) -> BitMask

Creates a new BitMask initialized to zero.

Source

pub fn full(len: usize) -> BitMask

Source

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

Sets the bit at the given index to 1. No-ops silently if the bit is already set so count stays accurate.

Source

pub fn unset(&mut self, index: usize)

Clears the bit at the given index to 0. No-ops silently if the bit is already clear so count stays accurate.

Source

pub fn is_set(&self, index: &usize) -> bool

Returns true if the bit at the given index is 1.

Source

pub const fn is_empty(&self) -> bool

Source

pub const fn is_full(&self) -> bool

Source

pub fn clear(&mut self)

Clears all bits (resets to zero) without reallocating.

Source

pub fn and(&mut self, other: &BitMask)

Performs a bitwise AND in-place (intersection). Recounts set bits via popcount after the operation.

Source

pub fn or(&mut self, other: &BitMask)

Performs a bitwise OR in-place (union). Recounts set bits via popcount after the operation.

Source

pub fn iter(&self) -> BitMaskIter<'_>

Returns a high-performance iterator over the indices of set bits.

Source

pub fn concat(self, b: BitMask) -> BitMask

Source

pub fn extend(&mut self, b: BitMask)

Source§

impl BitMask

Trait Implementations§

Source§

impl<T> BitAnd<T> for BitMask
where T: Into<BitMask>,

Source§

type Output = BitMask

The resulting type after applying the & operator.
Source§

fn bitand(self, other: T) -> BitMask

Performs the & operation. Read more
Source§

impl<T> BitOr<T> for BitMask
where T: Into<BitMask>,

Source§

type Output = BitMask

The resulting type after applying the | operator.
Source§

fn bitor(self, other: T) -> BitMask

Performs the | operation. Read more
Source§

impl Clone for BitMask

Source§

fn clone(&self) -> BitMask

Returns a duplicate 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 BitMask

Source§

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

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

impl Default for BitMask

Source§

fn default() -> BitMask

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

impl From<&BitMask> for BitMask

Source§

fn from(other: &BitMask) -> BitMask

Converts to this type from the input type.
Source§

impl<'a> IntoIterator for &'a BitMask

Source§

type Item = usize

The type of the elements being iterated over.
Source§

type IntoIter = BitMaskIter<'a>

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

fn into_iter(self) -> <&'a BitMask as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl Not for &BitMask

Source§

type Output = BitMask

The resulting type after applying the ! operator.
Source§

fn not(self) -> BitMask

Performs the unary ! operation. Read more
Source§

impl Not for BitMask

Source§

type Output = BitMask

The resulting type after applying the ! operator.
Source§

fn not(self) -> BitMask

Performs the unary ! operation. Read more

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.