pub struct BitVec { /* private fields */ }Expand description
A compact set of bits.
Iteration yields set positions rather than every position, so walking a sparse mask costs one step per member instead of one per candidate.
Implementations§
Source§impl BitVec
impl BitVec
Sourcepub fn with_capacity(len: u32) -> Self
pub fn with_capacity(len: u32) -> Self
Creates a set with room for len bits without reallocating.
Sourcepub fn get(&self, position: u32) -> Option<bool>
pub fn get(&self, position: u32) -> Option<bool>
Returns the bit at position, or None if it is past the end.
Sourcepub fn test(&self, position: u32) -> bool
pub fn test(&self, position: u32) -> bool
Returns the bit at position, treating a position past the end as unset.
Sourcepub fn set(&mut self, position: u32, value: bool)
pub fn set(&mut self, position: u32, value: bool)
Sets the bit at position, ignoring a position past the end.
Sourcepub fn count_ones(&self) -> u32
pub fn count_ones(&self) -> u32
The number of set bits.
Sourcepub fn ones(&self) -> Ones<'_> ⓘ
pub fn ones(&self) -> Ones<'_> ⓘ
The set positions, ascending.
Skips whole words that hold nothing, so a mask with one member in a million bits costs a scan of sixteen thousand words rather than a million tests.
A position space beyond u32 ends the walk rather than panicking.
Sourcepub fn intersect_with(&mut self, other: &Self)
pub fn intersect_with(&mut self, other: &Self)
Keeps only the bits also set in other.
Sourcepub fn union_with(&mut self, other: &Self)
pub fn union_with(&mut self, other: &Self)
Adds every bit set in other.
Bits of other beyond this set’s length are ignored; the length is a
property of the structure, not of the operation.
Source§impl BitVec
impl BitVec
Sourcepub fn try_from_iter<T: IntoIterator<Item = bool>>(iter: T) -> Option<Self>
pub fn try_from_iter<T: IntoIterator<Item = bool>>(iter: T) -> Option<Self>
Builds a bit vector, returning None if its position space is exhausted.
Trait Implementations§
impl Eq for BitVec
impl StructuralPartialEq for BitVec
Auto Trait Implementations§
impl Freeze for BitVec
impl RefUnwindSafe for BitVec
impl Send for BitVec
impl Sync for BitVec
impl Unpin for BitVec
impl UnsafeUnpin for BitVec
impl UnwindSafe for BitVec
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
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more