pub struct SharedBitVec { /* private fields */ }Implementations§
Sourcepub fn create(
path: impl AsRef<Path>,
capacity_bits: usize,
) -> Result<Self, BitVecError>
pub fn create( path: impl AsRef<Path>, capacity_bits: usize, ) -> Result<Self, BitVecError>
Obtain the bit vector at path, initializing an all-zero one
if the path does not yet exist and attaching to it if it does.
Attaching leaves set bits in place; a region built with a
different capacity is a LayoutMismatch.
reset reinitializes.
Sourcepub fn reset(
path: impl AsRef<Path>,
capacity_bits: usize,
) -> Result<Self, BitVecError>
pub fn reset( path: impl AsRef<Path>, capacity_bits: usize, ) -> Result<Self, BitVecError>
Truncate the bit vector at path and initialize an all-zero
one, discarding the bits live peers share. For a caller that
knows it owns the path.
pub fn open( path: impl AsRef<Path>, expected_capacity_bits: usize, ) -> Result<Self, BitVecError>
pub fn capacity_bits(&self) -> usize
pub fn capacity_words(&self) -> usize
Sourcepub fn set(&self, i: usize) -> Result<bool, BitVecError>
pub fn set(&self, i: usize) -> Result<bool, BitVecError>
Set bit i to 1. Returns the previous value at that bit.
Sourcepub fn clear(&self, i: usize) -> Result<bool, BitVecError>
pub fn clear(&self, i: usize) -> Result<bool, BitVecError>
Clear bit i to 0. Returns the previous value at that bit.
Sourcepub fn toggle(&self, i: usize) -> Result<bool, BitVecError>
pub fn toggle(&self, i: usize) -> Result<bool, BitVecError>
Flip bit i. Returns the new value at that bit.
Sourcepub fn set_range(&self, lo: usize, hi: usize) -> Result<(), BitVecError>
pub fn set_range(&self, lo: usize, hi: usize) -> Result<(), BitVecError>
Set all bits in lo..hi (exclusive end). Uses RMW on boundary
words and unconditional store on interior words.
Sourcepub fn clear_range(&self, lo: usize, hi: usize) -> Result<(), BitVecError>
pub fn clear_range(&self, lo: usize, hi: usize) -> Result<(), BitVecError>
Clear all bits in lo..hi (exclusive end). Same RMW-on-
boundary, store-on-interior pattern.
Sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Count total number of 1-bits across all words. O(words).
Sourcepub fn count_zeros(&self) -> usize
pub fn count_zeros(&self) -> usize
Count total number of 0-bits in the valid range.
pub fn is_all_set(&self) -> bool
pub fn is_all_clear(&self) -> bool
Sourcepub fn set_all(&self)
pub fn set_all(&self)
Set every bit. Unconditional Release-store on every word, with the last word masked to only valid bits so count_ones stays accurate.