pub struct BitSet<V: BitValue> { /* private fields */ }Expand description
A set of V, stored as a bit set.
Implementations§
Source§impl<V: BitValue> BitSet<V>
impl<V: BitValue> BitSet<V>
Sourcepub fn words(&self) -> &[Word] ⓘ
pub fn words(&self) -> &[Word] ⓘ
Returns a reference to the underlying Words making up this BitSet.
Note that the Word type varies in size and endianness between platforms, so if you want
to use this for cross-platform serialization, make sure to convert the data to something
portable first.
The number of Words that make up any given BitSet can also vary between platforms,
and is generally only guaranteed to be large enough to store
<V as BitValue>::MAX, but may be arbitrarily larger.
Sourcepub fn words_mut(&mut self) -> &mut [Word] ⓘ
pub fn words_mut(&mut self) -> &mut [Word] ⓘ
Returns a mutable reference to the underlying Words making up this BitSet.
You should not set any bits to 1 whose indices are larger than
<V as BitValue>::MAX. Doing so might cause the BitSet to behave
incorrectly.
Note that the Word type varies in size between platforms.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in this BitSet (the number of set bits).
Sourcepub fn insert(&mut self, value: V) -> bool
pub fn insert(&mut self, value: V) -> bool
Inserts value into self, setting the appropriate bit.
Returns true if value was newly inserted, or false if it was already present.
§Panics
Panics if value is larger than <V as BitValue>::MAX.
Trait Implementations§
Source§impl<V: BitValue> Extend<V> for BitSet<V>
impl<V: BitValue> Extend<V> for BitSet<V>
Source§fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
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)