pub struct DenseBitSet<T> { /* private fields */ }Expand description
A fixed-size bitset type with a dense representation.
Note 1: Since this bitset is dense, if your domain is big, and/or relatively
homogeneous (for example, with long runs of bits set or unset), then it may
be preferable to instead use a MixedBitSet, or an
IntervalSet. They should be more suited to
sparse, or highly-compressible, domains.
Note 2: 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.
Implementations§
Source§impl<T> DenseBitSet<T>
impl<T> DenseBitSet<T>
Sourcepub fn domain_size(&self) -> usize
pub fn domain_size(&self) -> usize
Gets the domain size.
Source§impl<T> DenseBitSet<T>where
T: Idx,
impl<T> DenseBitSet<T>where
T: Idx,
Sourcepub fn new_empty(domain_size: usize) -> DenseBitSet<T>
pub fn new_empty(domain_size: usize) -> DenseBitSet<T>
Creates a new, empty bitset with a given domain_size.
Sourcepub fn new_filled(domain_size: usize) -> DenseBitSet<T>
pub fn new_filled(domain_size: usize) -> DenseBitSet<T>
Creates a new, filled bitset with a given domain_size.
Sourcepub fn superset(&self, other: &DenseBitSet<T>) -> bool
pub fn superset(&self, other: &DenseBitSet<T>) -> bool
Is self is a (non-strict) superset of other?
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 contains_any(&self, elems: impl RangeBounds<T>) -> bool
pub fn contains_any(&self, elems: impl RangeBounds<T>) -> bool
Checks whether any bit in the given range is a 1.
Sourcepub fn iter(&self) -> BitIter<'_, T> ⓘ
pub fn iter(&self) -> BitIter<'_, T> ⓘ
Iterates over the indices of set bits in a sorted order.
pub fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T>
Sourcepub fn union<Rhs>(&mut self, other: &Rhs) -> boolwhere
DenseBitSet<T>: BitRelations<Rhs>,
pub fn union<Rhs>(&mut self, other: &Rhs) -> boolwhere
DenseBitSet<T>: 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
DenseBitSet<T>: BitRelations<Rhs>,
pub fn subtract<Rhs>(&mut self, other: &Rhs) -> boolwhere
DenseBitSet<T>: 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
DenseBitSet<T>: BitRelations<Rhs>,
pub fn intersect<Rhs>(&mut self, other: &Rhs) -> boolwhere
DenseBitSet<T>: BitRelations<Rhs>,
Sets self = self & other and return true if self changed.
(i.e., if any bits were removed).
Sourcepub fn union_not(&mut self, other: &DenseBitSet<T>)
pub fn union_not(&mut self, other: &DenseBitSet<T>)
Sets self = self | !other.
FIXME: Incorporate this into BitRelations and fill out
implementations for other bitset types, if needed.
Trait Implementations§
Source§impl<T> BitRelations<DenseBitSet<T>> for DenseBitSet<T>where
T: Idx,
impl<T> BitRelations<DenseBitSet<T>> for DenseBitSet<T>where
T: Idx,
fn union(&mut self, other: &DenseBitSet<T>) -> bool
fn subtract(&mut self, other: &DenseBitSet<T>) -> bool
fn intersect(&mut self, other: &DenseBitSet<T>) -> bool
Source§impl<T> Clone for DenseBitSet<T>
impl<T> Clone for DenseBitSet<T>
Source§fn clone(&self) -> DenseBitSet<T>
fn clone(&self) -> DenseBitSet<T>
Source§fn clone_from(&mut self, from: &DenseBitSet<T>)
fn clone_from(&mut self, from: &DenseBitSet<T>)
source. Read moreSource§impl<T> Debug for DenseBitSet<T>where
T: Idx,
impl<T> Debug for DenseBitSet<T>where
T: Idx,
impl<T> Eq for DenseBitSet<T>where
T: Eq,
Source§impl<T> From<DenseBitSet<T>> for GrowableBitSet<T>where
T: Idx,
impl<T> From<DenseBitSet<T>> for GrowableBitSet<T>where
T: Idx,
Source§fn from(bit_set: DenseBitSet<T>) -> GrowableBitSet<T>
fn from(bit_set: DenseBitSet<T>) -> GrowableBitSet<T>
Source§impl<T> From<GrowableBitSet<T>> for DenseBitSet<T>where
T: Idx,
impl<T> From<GrowableBitSet<T>> for DenseBitSet<T>where
T: Idx,
Source§fn from(bit_set: GrowableBitSet<T>) -> DenseBitSet<T>
fn from(bit_set: GrowableBitSet<T>) -> DenseBitSet<T>
Source§impl<T> Hash for DenseBitSet<T>where
T: Hash,
impl<T> Hash for DenseBitSet<T>where
T: Hash,
Source§impl<T> PartialEq for DenseBitSet<T>where
T: PartialEq,
impl<T> PartialEq for DenseBitSet<T>where
T: PartialEq,
Source§fn eq(&self, other: &DenseBitSet<T>) -> bool
fn eq(&self, other: &DenseBitSet<T>) -> bool
self and other values to be equal, and is used by ==.impl<T> StructuralPartialEq for DenseBitSet<T>where
T: PartialEq,
Auto Trait Implementations§
impl<T> Freeze for DenseBitSet<T>
impl<T> RefUnwindSafe for DenseBitSet<T>where
T: RefUnwindSafe,
impl<T> Send for DenseBitSet<T>where
T: Send,
impl<T> Sync for DenseBitSet<T>where
T: Sync,
impl<T> Unpin for DenseBitSet<T>where
T: Unpin,
impl<T> UnsafeUnpin for DenseBitSet<T>
impl<T> UnwindSafe for DenseBitSet<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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more