pub struct BitString { /* private fields */ }Implementations§
Source§impl BitString
impl BitString
Sourcepub fn as_words(&self) -> &[u64]
pub fn as_words(&self) -> &[u64]
Returns the internal little-endian words.
Bit index i is stored in word i / 64, bit offset i % 64.
Unused high bits in the last word are guaranteed to be zero.
pub fn first(&self) -> Option<bool>
Sourcepub fn get_chunk(&self, bit_start: usize) -> u64
pub fn get_chunk(&self, bit_start: usize) -> u64
Reads up to 64 bits starting at bit_start, returning them in the
low bits of a u64.
Bits beyond self.len() are treated as zero.
pub fn last(&self) -> Option<bool>
pub fn to_bool_vec(&self) -> Vec<bool>
Source§impl BitString
impl BitString
Sourcepub fn and(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
pub fn and(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
Returns self & rhs without mutating either input.
Sourcepub fn and_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>
pub fn and_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>
Replaces self with self & rhs.
Sourcepub fn and_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
pub fn and_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
Consumes self, reuses its backing storage, and returns self & rhs.
Source§impl BitString
impl BitString
Sourcepub fn or(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
pub fn or(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
Returns self & rhs without mutating either input.
Sourcepub fn or_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>
pub fn or_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>
Replaces self with self & rhs.
Sourcepub fn or_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
pub fn or_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
Consumes self, reuses its backing storage, and returns self & rhs.
Source§impl BitString
impl BitString
Sourcepub fn xor(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
pub fn xor(&self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
Returns self & rhs without mutating either input.
Sourcepub fn xor_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>
pub fn xor_assign(&mut self, rhs: &Self) -> Result<(), BitStringLenMismatch>
Replaces self with self & rhs.
Sourcepub fn xor_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
pub fn xor_into(self, rhs: &Self) -> Result<Self, BitStringLenMismatch>
Consumes self, reuses its backing stxorage, and returns self & rhs.
Source§impl BitString
impl BitString
pub fn count_ones(&self) -> usize
pub fn count_zeros(&self) -> usize
Source§impl BitString
impl BitString
Sourcepub fn shl_assign(&mut self, amount: usize)
pub fn shl_assign(&mut self, amount: usize)
Replaces self with self << amount, filling new bits with zero.
Source§impl BitString
impl BitString
Sourcepub fn shr_assign(&mut self, amount: usize)
pub fn shr_assign(&mut self, amount: usize)
Replaces self with self >> amount, filling new bits with zero.
Source§impl BitString
impl BitString
pub fn new() -> Self
pub fn repeat(value: bool, len: usize) -> Self
pub fn zeros(len: usize) -> Self
pub fn ones(len: usize) -> Self
Sourcepub fn from_words(words: &[u64], len: usize) -> Option<Self>
pub fn from_words(words: &[u64], len: usize) -> Option<Self>
Constructs a bit string from packed little-endian words.
The input must contain exactly enough words for len.
Unused high bits in the last word are masked out.
Source§impl BitString
impl BitString
pub fn set(&mut self, index: usize, value: bool) -> Option<bool>
Sourcepub fn set_chunk(&mut self, bit_start: usize, value: u64, len: usize)
pub fn set_chunk(&mut self, bit_start: usize, value: u64, len: usize)
Writes len bits of value starting at bit_start, OR-ing them
with the existing bits. Bits beyond self.len() are ignored.
Only the low len bits of value are used; higher bits are
masked out.
pub fn push(&mut self, value: bool)
pub fn pop(&mut self) -> Option<bool>
pub fn truncate(&mut self, len: usize)
pub fn clear(&mut self)
pub fn insert(&mut self, index: usize, value: bool)
pub fn remove(&mut self, index: usize) -> bool
pub fn push_bits(&mut self, rhs: &Self)
pub fn insert_bits(&mut self, index: usize, rhs: &Self)
pub fn split_off(&mut self, at: usize) -> Self
pub fn replace_interval(&mut self, interval: UsizeCO, replacement: &Self)
pub fn drain_interval(&mut self, interval: UsizeCO) -> Self
pub fn retain<F>(&mut self, f: F)
Source§impl BitString
impl BitString
pub fn slice(&self, interval: UsizeCO) -> Self
pub fn slice_from(&self, start: usize) -> Self
pub fn slice_until(&self, end: usize) -> Self
Source§impl BitString
impl BitString
pub fn matches_at(&self, index: usize, pattern: &Self) -> bool
pub fn starts_with(&self, prefix: &Self) -> bool
pub fn ends_with(&self, suffix: &Self) -> bool
pub fn contains_bits(&self, needle: &Self) -> bool
pub fn find_bits(&self, needle: &Self) -> Option<usize>
pub fn rfind_bits(&self, needle: &Self) -> Option<usize>
pub fn strip_prefix(&self, prefix: &Self) -> Option<Self>
pub fn strip_suffix(&self, suffix: &Self) -> Option<Self>
Trait Implementations§
impl Eq for BitString
Source§impl<'a> Extend<&'a bool> for BitString
impl<'a> Extend<&'a bool> for BitString
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = &'a bool>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = &'a bool>,
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 Extend<bool> for BitString
impl Extend<bool> for BitString
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = bool>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = bool>,
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)