Struct rustc_index::bit_set::BitSet
source · pub struct BitSet<T> {
domain_size: usize,
words: Vec<u64>,
marker: PhantomData<T>,
}
Expand description
A fixed-size bitset type with a dense representation.
NOTE: Use GrowableBitSet
if you need support for resizing after creation.
T
is an index type, typically a newtyped usize
wrapper, but it can also
just be usize
.
All operations that involve an element will panic if the element is equal to or greater than the domain size. All operations that involve two bitsets will panic if the bitsets have differing domain sizes.
Fields
domain_size: usize
words: Vec<u64>
marker: PhantomData<T>
Implementations
sourceimpl<T> BitSet<T>
impl<T> BitSet<T>
sourcepub fn domain_size(&self) -> usize
pub fn domain_size(&self) -> usize
Gets the domain size.
sourceimpl<T: Idx> BitSet<T>
impl<T: Idx> BitSet<T>
sourcepub fn new_empty(domain_size: usize) -> BitSet<T>
pub fn new_empty(domain_size: usize) -> BitSet<T>
Creates a new, empty bitset with a given domain_size
.
sourcepub fn new_filled(domain_size: usize) -> BitSet<T>
pub fn new_filled(domain_size: usize) -> BitSet<T>
Creates a new, filled bitset with a given domain_size
.
sourcefn clear_excess_bits(&mut self)
fn clear_excess_bits(&mut self)
Clear excess bits in the final word.
pub fn insert_range(&mut self, elems: impl RangeBounds<T>)
sourcepub fn insert_all(&mut self)
pub fn insert_all(&mut self)
Sets all bits to true.
sourcepub fn iter(&self) -> BitIter<'_, T>ⓘNotable traits for BitIter<'a, T>impl<'a, T: Idx> Iterator for BitIter<'a, T> type Item = T;
pub fn iter(&self) -> BitIter<'_, T>ⓘNotable traits for BitIter<'a, T>impl<'a, T: Idx> Iterator for BitIter<'a, T> type Item = T;
Iterates over the indices of set bits in a sorted order.
sourcepub fn to_hybrid(&self) -> HybridBitSet<T>
pub fn to_hybrid(&self) -> HybridBitSet<T>
Duplicates the set as a hybrid set.
sourcefn reverse_union_sparse(&mut self, sparse: &SparseBitSet<T>) -> bool
fn reverse_union_sparse(&mut self, sparse: &SparseBitSet<T>) -> bool
Set self = self | other
. In contrast to union
returns true
if the set contains at
least one bit that is not in other
(i.e. other
is not a superset of self
).
This is an optimization for union of a hybrid bitset.
fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T>
sourcepub fn union<Rhs>(&mut self, other: &Rhs) -> boolwhere
Self: BitRelations<Rhs>,
pub fn union<Rhs>(&mut self, other: &Rhs) -> boolwhere
Self: BitRelations<Rhs>,
Sets self = self | other
and returns true
if self
changed
(i.e., if new bits were added).
sourcepub fn subtract<Rhs>(&mut self, other: &Rhs) -> boolwhere
Self: BitRelations<Rhs>,
pub fn subtract<Rhs>(&mut self, other: &Rhs) -> boolwhere
Self: BitRelations<Rhs>,
Sets self = self - other
and returns true
if self
changed.
(i.e., if any bits were removed).
sourcepub fn intersect<Rhs>(&mut self, other: &Rhs) -> boolwhere
Self: BitRelations<Rhs>,
pub fn intersect<Rhs>(&mut self, other: &Rhs) -> boolwhere
Self: BitRelations<Rhs>,
Sets self = self & other
and return true
if self
changed.
(i.e., if any bits were removed).
Trait Implementations
sourceimpl<T: Idx> BitRelations<BitSet<T>> for BitSet<T>
impl<T: Idx> BitRelations<BitSet<T>> for BitSet<T>
sourceimpl<T: Idx> BitRelations<BitSet<T>> for HybridBitSet<T>
impl<T: Idx> BitRelations<BitSet<T>> for HybridBitSet<T>
sourceimpl<T: Idx> BitRelations<ChunkedBitSet<T>> for BitSet<T>
impl<T: Idx> BitRelations<ChunkedBitSet<T>> for BitSet<T>
fn union(&mut self, other: &ChunkedBitSet<T>) -> bool
fn subtract(&mut self, _other: &ChunkedBitSet<T>) -> bool
fn intersect(&mut self, other: &ChunkedBitSet<T>) -> bool
sourceimpl<T: Idx> BitRelations<HybridBitSet<T>> for BitSet<T>
impl<T: Idx> BitRelations<HybridBitSet<T>> for BitSet<T>
fn union(&mut self, other: &HybridBitSet<T>) -> bool
fn subtract(&mut self, other: &HybridBitSet<T>) -> bool
fn intersect(&mut self, other: &HybridBitSet<T>) -> bool
sourceimpl<T: Idx> From<BitSet<T>> for GrowableBitSet<T>
impl<T: Idx> From<BitSet<T>> for GrowableBitSet<T>
sourceimpl<T: Idx> From<GrowableBitSet<T>> for BitSet<T>
impl<T: Idx> From<GrowableBitSet<T>> for BitSet<T>
sourcefn from(bit_set: GrowableBitSet<T>) -> Self
fn from(bit_set: GrowableBitSet<T>) -> Self
sourceimpl<T: PartialEq> PartialEq<BitSet<T>> for BitSet<T>
impl<T: PartialEq> PartialEq<BitSet<T>> for BitSet<T>
impl<T: Eq> Eq for BitSet<T>
impl<T> StructuralEq for BitSet<T>
impl<T> StructuralPartialEq for BitSet<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for BitSet<T>where
T: RefUnwindSafe,
impl<T> Send for BitSet<T>where
T: Send,
impl<T> Sync for BitSet<T>where
T: Sync,
impl<T> Unpin for BitSet<T>where
T: Unpin,
impl<T> UnwindSafe for BitSet<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes