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> Freeze for HybridBitSet<T>where
T: Freeze,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for 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.