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.