Struct fixedbitset::FixedBitSet 
source · [−]pub struct FixedBitSet { /* private fields */ }Expand description
FixedBitSet is a simple fixed size set of bits that each can
be enabled (1 / true) or disabled (0 / false).
The bit set has a fixed capacity in terms of enabling bits (and the
capacity can grow using the grow method).
Derived traits depend on both the zeros and ones, so [0,1] is not equal to [0,1,0].
Implementations
sourceimpl FixedBitSet
 
impl FixedBitSet
sourcepub fn with_capacity(bits: usize) -> Self
 
pub fn with_capacity(bits: usize) -> Self
Create a new FixedBitSet with a specific number of bits, all initially clear.
sourcepub fn with_capacity_and_blocks<I: IntoIterator<Item = u32>>(
    bits: usize, 
    blocks: I
) -> Self
 
pub fn with_capacity_and_blocks<I: IntoIterator<Item = u32>>(
    bits: usize, 
    blocks: I
) -> Self
Create a new FixedBitSet with a specific number of bits, initialized from provided blocks.
If the blocks are not the exact size needed for the capacity they will be padded with zeros (if shorter) or truncated to the capacity (if longer).
For example:
let data = vec![4];
let bs = fixedbitset::FixedBitSet::with_capacity_and_blocks(4, data);
assert_eq!(format!("{:b}", bs), "0010");sourcepub fn len(&self) -> usize
 
pub fn len(&self) -> usize
The length of the FixedBitSet in bits.
Note: len includes both set and unset bits.
let bitset = FixedBitSet::with_capacity(10);
// there are 0 set bits, but 10 unset bits
assert_eq!(bitset.len(), 10);len does not return the count of set bits. For that, use
bitset.count_ones(..) instead.
sourcepub fn is_empty(&self) -> bool
 
pub fn is_empty(&self) -> bool
true if the FixedBitSet is empty.
Note that an “empty” FixedBitSet is a FixedBitSet with
no bits (meaning: it’s length is zero). If you want to check
if all bits are unset, use FixedBitSet::is_clear.
let bitset = FixedBitSet::with_capacity(10);
assert!(!bitset.is_empty());
let bitset = FixedBitSet::with_capacity(0);
assert!(bitset.is_empty());sourcepub fn is_clear(&self) -> bool
 
pub fn is_clear(&self) -> bool
true if all bits in the FixedBitSet are unset.
As opposed to FixedBitSet::is_empty, which is true only for
sets without any bits, set or unset.
let mut bitset = FixedBitSet::with_capacity(10);
assert!(bitset.is_clear());
bitset.insert(2);
assert!(!bitset.is_clear());This is equivalent to bitset.count_ones(..) == 0.
sourcepub fn contains(&self, bit: usize) -> bool
 
pub fn contains(&self, bit: usize) -> bool
Return true if the bit is enabled in the FixedBitSet, false otherwise.
Note: bits outside the capacity are always disabled.
Note: Also available with index syntax: bitset[bit].
sourcepub fn put(&mut self, bit: usize) -> bool
 
pub fn put(&mut self, bit: usize) -> bool
Enable bit, and return its previous value.
Panics if bit is out of bounds.
sourcepub fn toggle(&mut self, bit: usize)
 
pub fn toggle(&mut self, bit: usize)
Toggle bit (inverting its state).
Panics if bit is out of bounds
sourcepub fn copy_bit(&mut self, from: usize, to: usize)
 
pub fn copy_bit(&mut self, from: usize, to: usize)
Copies boolean value from specified bit to the specified bit.
Panics if to is out of bounds.
sourcepub fn count_ones<T: IndexRange>(&self, range: T) -> usize
 
pub fn count_ones<T: IndexRange>(&self, range: T) -> usize
Count the number of set bits in the given bit range.
Use .. to count the whole content of the bitset.
Panics if the range extends past the end of the bitset.
sourcepub fn set_range<T: IndexRange>(&mut self, range: T, enabled: bool)
 
pub fn set_range<T: IndexRange>(&mut self, range: T, enabled: bool)
Sets every bit in the given range to the given state (enabled)
Use .. to set the whole bitset.
Panics if the range extends past the end of the bitset.
sourcepub fn insert_range<T: IndexRange>(&mut self, range: T)
 
pub fn insert_range<T: IndexRange>(&mut self, range: T)
Enables every bit in the given range.
Use .. to make the whole bitset ones.
Panics if the range extends past the end of the bitset.
sourcepub fn toggle_range<T: IndexRange>(&mut self, range: T)
 
pub fn toggle_range<T: IndexRange>(&mut self, range: T)
Toggles (inverts) every bit in the given range.
Use .. to toggle the whole bitset.
Panics if the range extends past the end of the bitset.
sourcepub fn as_mut_slice(&mut self) -> &mut [u32]
 
pub fn as_mut_slice(&mut self) -> &mut [u32]
View the bitset as a mutable slice of u32 blocks. Writing past the bitlength in the last
will cause contains to return potentially incorrect results for bits past the bitlength.
sourcepub fn ones(&self) -> Ones<'_>ⓘNotable traits for Ones<'a>impl<'a> Iterator for Ones<'a>    type Item = usize;
 
pub fn ones(&self) -> Ones<'_>ⓘNotable traits for Ones<'a>impl<'a> Iterator for Ones<'a>    type Item = usize;
Iterates over all enabled bits.
Iterator element is the index of the 1 bit, type usize.
sourcepub fn intersection<'a>(&'a self, other: &'a FixedBitSet) -> Intersection<'a>ⓘNotable traits for Intersection<'a>impl<'a> Iterator for Intersection<'a>    type Item = usize;
 
pub fn intersection<'a>(&'a self, other: &'a FixedBitSet) -> Intersection<'a>ⓘNotable traits for Intersection<'a>impl<'a> Iterator for Intersection<'a>    type Item = usize;
Returns a lazy iterator over the intersection of two FixedBitSets
sourcepub fn union<'a>(&'a self, other: &'a FixedBitSet) -> Union<'a>ⓘNotable traits for Union<'a>impl<'a> Iterator for Union<'a>    type Item = usize;
 
pub fn union<'a>(&'a self, other: &'a FixedBitSet) -> Union<'a>ⓘNotable traits for Union<'a>impl<'a> Iterator for Union<'a>    type Item = usize;
Returns a lazy iterator over the union of two FixedBitSets.
sourcepub fn difference<'a>(&'a self, other: &'a FixedBitSet) -> Difference<'a>ⓘNotable traits for Difference<'a>impl<'a> Iterator for Difference<'a>    type Item = usize;
 
pub fn difference<'a>(&'a self, other: &'a FixedBitSet) -> Difference<'a>ⓘNotable traits for Difference<'a>impl<'a> Iterator for Difference<'a>    type Item = usize;
Returns a lazy iterator over the difference of two FixedBitSets. The difference of a
and b is the elements of a which are not in b.
sourcepub fn symmetric_difference<'a>(
    &'a self, 
    other: &'a FixedBitSet
) -> SymmetricDifference<'a>ⓘNotable traits for SymmetricDifference<'a>impl<'a> Iterator for SymmetricDifference<'a>    type Item = usize;
 
pub fn symmetric_difference<'a>(
    &'a self, 
    other: &'a FixedBitSet
) -> SymmetricDifference<'a>ⓘNotable traits for SymmetricDifference<'a>impl<'a> Iterator for SymmetricDifference<'a>    type Item = usize;
Returns a lazy iterator over the symmetric difference of two FixedBitSets.
The symmetric difference of a and b is the elements of one, but not both, sets.
sourcepub fn union_with(&mut self, other: &FixedBitSet)
 
pub fn union_with(&mut self, other: &FixedBitSet)
In-place union of two FixedBitSets.
On calling this method, self’s capacity may be increased to match other’s.
sourcepub fn intersect_with(&mut self, other: &FixedBitSet)
 
pub fn intersect_with(&mut self, other: &FixedBitSet)
In-place intersection of two FixedBitSets.
On calling this method, self’s capacity will remain the same as before.
sourcepub fn difference_with(&mut self, other: &FixedBitSet)
 
pub fn difference_with(&mut self, other: &FixedBitSet)
In-place difference of two FixedBitSets.
On calling this method, self’s capacity will remain the same as before.
sourcepub fn symmetric_difference_with(&mut self, other: &FixedBitSet)
 
pub fn symmetric_difference_with(&mut self, other: &FixedBitSet)
In-place symmetric difference of two FixedBitSets.
On calling this method, self’s capacity may be increased to match other’s.
sourcepub fn is_disjoint(&self, other: &FixedBitSet) -> bool
 
pub fn is_disjoint(&self, other: &FixedBitSet) -> bool
Returns true if self has no elements in common with other. This
is equivalent to checking for an empty intersection.
sourcepub fn is_subset(&self, other: &FixedBitSet) -> bool
 
pub fn is_subset(&self, other: &FixedBitSet) -> bool
Returns true if the set is a subset of another, i.e. other contains
at least all the values in self.
sourcepub fn is_superset(&self, other: &FixedBitSet) -> bool
 
pub fn is_superset(&self, other: &FixedBitSet) -> bool
Returns true if the set is a superset of another, i.e. self contains
at least all the values in other.
Trait Implementations
sourceimpl Binary for FixedBitSet
 
impl Binary for FixedBitSet
sourceimpl<'a> BitAnd<&'a FixedBitSet> for &'a FixedBitSet
 
impl<'a> BitAnd<&'a FixedBitSet> for &'a FixedBitSet
type Output = FixedBitSet
type Output = FixedBitSet
The resulting type after applying the & operator.
sourcefn bitand(self, other: &FixedBitSet) -> FixedBitSet
 
fn bitand(self, other: &FixedBitSet) -> FixedBitSet
Performs the & operation. Read more
sourceimpl<'a> BitAndAssign<&'_ FixedBitSet> for FixedBitSet
 
impl<'a> BitAndAssign<&'_ FixedBitSet> for FixedBitSet
sourcefn bitand_assign(&mut self, other: &Self)
 
fn bitand_assign(&mut self, other: &Self)
Performs the &= operation. Read more
sourceimpl<'a> BitAndAssign<FixedBitSet> for FixedBitSet
 
impl<'a> BitAndAssign<FixedBitSet> for FixedBitSet
sourcefn bitand_assign(&mut self, other: Self)
 
fn bitand_assign(&mut self, other: Self)
Performs the &= operation. Read more
sourceimpl<'a> BitOr<&'a FixedBitSet> for &'a FixedBitSet
 
impl<'a> BitOr<&'a FixedBitSet> for &'a FixedBitSet
type Output = FixedBitSet
type Output = FixedBitSet
The resulting type after applying the | operator.
sourcefn bitor(self, other: &FixedBitSet) -> FixedBitSet
 
fn bitor(self, other: &FixedBitSet) -> FixedBitSet
Performs the | operation. Read more
sourceimpl<'a> BitOrAssign<&'_ FixedBitSet> for FixedBitSet
 
impl<'a> BitOrAssign<&'_ FixedBitSet> for FixedBitSet
sourcefn bitor_assign(&mut self, other: &Self)
 
fn bitor_assign(&mut self, other: &Self)
Performs the |= operation. Read more
sourceimpl<'a> BitOrAssign<FixedBitSet> for FixedBitSet
 
impl<'a> BitOrAssign<FixedBitSet> for FixedBitSet
sourcefn bitor_assign(&mut self, other: Self)
 
fn bitor_assign(&mut self, other: Self)
Performs the |= operation. Read more
sourceimpl<'a> BitXor<&'a FixedBitSet> for &'a FixedBitSet
 
impl<'a> BitXor<&'a FixedBitSet> for &'a FixedBitSet
type Output = FixedBitSet
type Output = FixedBitSet
The resulting type after applying the ^ operator.
sourcefn bitxor(self, other: &FixedBitSet) -> FixedBitSet
 
fn bitxor(self, other: &FixedBitSet) -> FixedBitSet
Performs the ^ operation. Read more
sourceimpl<'a> BitXorAssign<&'_ FixedBitSet> for FixedBitSet
 
impl<'a> BitXorAssign<&'_ FixedBitSet> for FixedBitSet
sourcefn bitxor_assign(&mut self, other: &Self)
 
fn bitxor_assign(&mut self, other: &Self)
Performs the ^= operation. Read more
sourceimpl<'a> BitXorAssign<FixedBitSet> for FixedBitSet
 
impl<'a> BitXorAssign<FixedBitSet> for FixedBitSet
sourcefn bitxor_assign(&mut self, other: Self)
 
fn bitxor_assign(&mut self, other: Self)
Performs the ^= operation. Read more
sourceimpl Clone for FixedBitSet
 
impl Clone for FixedBitSet
sourceimpl Debug for FixedBitSet
 
impl Debug for FixedBitSet
sourceimpl Default for FixedBitSet
 
impl Default for FixedBitSet
sourcefn default() -> FixedBitSet
 
fn default() -> FixedBitSet
Returns the “default value” for a type. Read more
sourceimpl Display for FixedBitSet
 
impl Display for FixedBitSet
sourceimpl Extend<usize> for FixedBitSet
 
impl Extend<usize> for FixedBitSet
Sets the bit at index i to true for each item i in the input src.
sourcefn extend<I: IntoIterator<Item = usize>>(&mut self, src: I)
 
fn extend<I: IntoIterator<Item = usize>>(&mut self, src: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
 
fn extend_one(&mut self, item: A)
extend_one)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
 
fn extend_reserve(&mut self, additional: usize)
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl FromIterator<usize> for FixedBitSet
 
impl FromIterator<usize> for FixedBitSet
Return a FixedBitSet containing bits set to true for every bit index in the iterator, other bits are set to false.
sourcefn from_iter<I: IntoIterator<Item = usize>>(src: I) -> Self
 
fn from_iter<I: IntoIterator<Item = usize>>(src: I) -> Self
Creates a value from an iterator. Read more
sourceimpl Hash for FixedBitSet
 
impl Hash for FixedBitSet
sourceimpl Index<usize> for FixedBitSet
 
impl Index<usize> for FixedBitSet
Return true if the bit is enabled in the bitset, or false otherwise.
Note: bits outside the capacity are always disabled, and thus indexing a FixedBitSet will not panic.
sourceimpl Ord for FixedBitSet
 
impl Ord for FixedBitSet
sourceimpl PartialEq<FixedBitSet> for FixedBitSet
 
impl PartialEq<FixedBitSet> for FixedBitSet
sourcefn eq(&self, other: &FixedBitSet) -> bool
 
fn eq(&self, other: &FixedBitSet) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &FixedBitSet) -> bool
 
fn ne(&self, other: &FixedBitSet) -> bool
This method tests for !=.
sourceimpl PartialOrd<FixedBitSet> for FixedBitSet
 
impl PartialOrd<FixedBitSet> for FixedBitSet
sourcefn partial_cmp(&self, other: &FixedBitSet) -> Option<Ordering>
 
fn partial_cmp(&self, other: &FixedBitSet) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
 
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
 
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Eq for FixedBitSet
impl StructuralEq for FixedBitSet
impl StructuralPartialEq for FixedBitSet
Auto Trait Implementations
impl RefUnwindSafe for FixedBitSet
impl Send for FixedBitSet
impl Sync for FixedBitSet
impl Unpin for FixedBitSet
impl UnwindSafe for FixedBitSet
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
    T: ?Sized, 
 
impl<T> BorrowMut<T> for T where
    T: ?Sized, 
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
    T: Clone, 
 
impl<T> ToOwned for T where
    T: Clone, 
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
 
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more