Enum rustc_index::bit_set::HybridBitSet
source · pub enum HybridBitSet<T> {
Sparse(SparseBitSet<T>),
Dense(BitSet<T>),
}
Expand description
A fixed-size bitset type with a hybrid representation: sparse when there
are up to a SPARSE_MAX
elements in the set, but dense when there are more
than SPARSE_MAX
.
This type is especially efficient for sets that typically have a small
number of elements, but a large domain_size
, and are cleared frequently.
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.
Variants§
Sparse(SparseBitSet<T>)
Dense(BitSet<T>)
Implementations§
source§impl<T: Idx> HybridBitSet<T>
impl<T: Idx> HybridBitSet<T>
pub fn new_empty(domain_size: usize) -> Self
pub fn domain_size(&self) -> usize
pub fn clear(&mut self)
pub fn contains(&self, elem: T) -> bool
pub fn superset(&self, other: &HybridBitSet<T>) -> bool
pub fn is_empty(&self) -> bool
sourcepub fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T>where
T: Ord,
pub fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T>where T: Ord,
Returns the previous element present in the bitset from elem
,
inclusively of elem. That is, will return Some(elem)
if elem is in the
bitset.
pub fn insert(&mut self, elem: T) -> bool
pub fn insert_range(&mut self, elems: impl RangeBounds<T>)
pub fn insert_all(&mut self)
pub fn remove(&mut self, elem: T) -> bool
pub fn iter(&self) -> HybridIter<'_, 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§
source§impl<T: Idx> BitRelations<BitSet<T>> for HybridBitSet<T>
impl<T: Idx> BitRelations<BitSet<T>> for HybridBitSet<T>
source§impl<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
source§impl<T: Idx> BitRelations<HybridBitSet<T>> for ChunkedBitSet<T>
impl<T: Idx> BitRelations<HybridBitSet<T>> for ChunkedBitSet<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
source§impl<T: Idx> BitRelations<HybridBitSet<T>> for HybridBitSet<T>
impl<T: Idx> BitRelations<HybridBitSet<T>> for HybridBitSet<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
source§impl<T: Clone> Clone for HybridBitSet<T>
impl<T: Clone> Clone for HybridBitSet<T>
source§fn clone(&self) -> HybridBitSet<T>
fn clone(&self) -> HybridBitSet<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<T> RefUnwindSafe for HybridBitSet<T>where T: RefUnwindSafe,
impl<T> Send for HybridBitSet<T>where T: Send,
impl<T> Sync for HybridBitSet<T>where T: Sync,
impl<T> Unpin for HybridBitSet<T>where T: Unpin,
impl<T> UnwindSafe for HybridBitSet<T>where T: UnwindSafe,
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
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.