pub enum MixedBitSet<T> {
Small(DenseBitSet<T>),
Large(ChunkedBitSet<T>),
}
Expand description
A bitset with a mixed representation, using DenseBitSet
for small and
medium bitsets, and ChunkedBitSet
for large bitsets, i.e. those with
enough bits for at least two chunks. This is a good choice for many bitsets
that can have large domain sizes (e.g. 5000+).
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§
Small(DenseBitSet<T>)
Large(ChunkedBitSet<T>)
Implementations§
Source§impl<T> MixedBitSet<T>
impl<T> MixedBitSet<T>
pub fn domain_size(&self) -> usize
Source§impl<T: Idx> MixedBitSet<T>
impl<T: Idx> MixedBitSet<T>
pub fn new_empty(domain_size: usize) -> MixedBitSet<T>
pub fn is_empty(&self) -> bool
pub fn contains(&self, elem: T) -> bool
pub fn insert(&mut self, elem: T) -> bool
pub fn insert_all(&mut self)
pub fn remove(&mut self, elem: T) -> bool
pub fn iter(&self) -> MixedBitIter<'_, T> ⓘ
pub fn clear(&mut self)
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<MixedBitSet<T>> for MixedBitSet<T>
impl<T: Idx> BitRelations<MixedBitSet<T>> for MixedBitSet<T>
fn union(&mut self, other: &MixedBitSet<T>) -> bool
fn subtract(&mut self, other: &MixedBitSet<T>) -> bool
fn intersect(&mut self, _other: &MixedBitSet<T>) -> bool
Source§impl<T> Clone for MixedBitSet<T>
impl<T> Clone for MixedBitSet<T>
Source§fn clone_from(&mut self, from: &Self)
fn clone_from(&mut self, from: &Self)
WARNING: this implementation of clone_from may panic if the two
bitsets have different domain sizes. This constraint is not inherent to
clone_from
, but it works with the existing call sites and allows a
faster implementation, which is important because this function is hot.
Source§impl<T: Idx> Debug for MixedBitSet<T>
impl<T: Idx> Debug for MixedBitSet<T>
Source§impl<T: PartialEq> PartialEq for MixedBitSet<T>
impl<T: PartialEq> PartialEq for MixedBitSet<T>
impl<T: Eq> Eq for MixedBitSet<T>
impl<T> StructuralPartialEq for MixedBitSet<T>
Auto Trait Implementations§
impl<T> Freeze for MixedBitSet<T>
impl<T> RefUnwindSafe for MixedBitSet<T>where
T: RefUnwindSafe,
impl<T> !Send for MixedBitSet<T>
impl<T> !Sync for MixedBitSet<T>
impl<T> Unpin for MixedBitSet<T>where
T: Unpin,
impl<T> UnwindSafe for MixedBitSet<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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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: 40 bytes
Size for each variant:
Small
: 32 bytesLarge
: 24 bytes