pub struct BitVector { /* private fields */ }Implementations§
Source§impl BitVector
impl BitVector
Sourcepub fn new(len: usize) -> Self
pub fn new(len: usize) -> Self
Creates a new BitVector with the specified number of bits, all initialized to false
Sourcepub fn from_binary_str(s: &str) -> Result<Self>
pub fn from_binary_str(s: &str) -> Result<Self>
Creates a BitVector from a binary string (e.g., “101010”)
Sourcepub fn get(&self, index: usize) -> bool
pub fn get(&self, index: usize) -> bool
Gets the value of the bit at the specified index Panics if index is out of bounds
Sourcepub fn set(&mut self, index: usize, value: bool)
pub fn set(&mut self, index: usize, value: bool)
Sets the value of the bit at the specified index Panics if index is out of bounds
Sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Counts the number of bits set to true
Sourcepub fn count_zeros(&self) -> usize
pub fn count_zeros(&self) -> usize
Counts the number of bits set to false
Sourcepub fn iter<'a>(&'a self) -> BitVectorIter<'a> ⓘ
pub fn iter<'a>(&'a self) -> BitVectorIter<'a> ⓘ
Returns an iterator over the bits
Sourcepub fn and(&mut self, other: &BitVector)
pub fn and(&mut self, other: &BitVector)
Performs a bitwise AND with another bitvector Panics if bitvectors have different lengths
Sourcepub fn or(&mut self, other: &BitVector)
pub fn or(&mut self, other: &BitVector)
Performs a bitwise OR with another bitvector Panics if bitvectors have different lengths
Sourcepub fn xor(&mut self, other: &BitVector)
pub fn xor(&mut self, other: &BitVector)
Performs a bitwise XOR with another bitvector Panics if bitvectors have different lengths
Sourcepub fn to_binary_string(&self) -> String
pub fn to_binary_string(&self) -> String
Returns the bitvector as a binary string
Trait Implementations§
Source§impl Decode for BitVector
impl Decode for BitVector
async fn decode_async(reader: &mut impl AsyncDecoder) -> Result<Self>
fn decode(reader: &mut impl Decoder) -> Result<Self>
impl Eq for BitVector
impl StructuralPartialEq for BitVector
Auto Trait Implementations§
impl Freeze for BitVector
impl RefUnwindSafe for BitVector
impl Send for BitVector
impl Sync for BitVector
impl Unpin for BitVector
impl UnsafeUnpin for BitVector
impl UnwindSafe for BitVector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.