pub struct BitSet { /* private fields */ }
Expand description
A BitSet
is a simple set designed to track which indices are placed
into it.
Note, a BitSet
is limited by design to only usize**4
indices.
Adding beyond this limit will cause the BitSet
to panic.
Implementations§
source§impl BitSet
impl BitSet
sourcepub fn with_capacity(max: u32) -> BitSet
pub fn with_capacity(max: u32) -> BitSet
Creates an empty BitSet
, preallocated for up to max
indices.
sourcepub fn add(&mut self, id: u32) -> bool
pub fn add(&mut self, id: u32) -> bool
Adds id
to the BitSet
. Returns true
if the value was
already in the set.
sourcepub fn remove(&mut self, id: u32) -> bool
pub fn remove(&mut self, id: u32) -> bool
Removes id
from the set, returns true
if the value
was removed, and false
if the value was not set
to begin with.
sourcepub fn contains_set(&self, other: &BitSet) -> bool
pub fn contains_set(&self, other: &BitSet) -> bool
Returns true
if all ids in other
are contained in this set
Trait Implementations§
source§impl<'a, T> BitAnd<T> for &'a BitSetwhere
T: BitSetLike,
impl<'a, T> BitAnd<T> for &'a BitSetwhere
T: BitSetLike,
source§impl<T> BitAnd<T> for BitSetwhere
T: BitSetLike,
impl<T> BitAnd<T> for BitSetwhere
T: BitSetLike,
source§impl<'a, T> BitOr<T> for &'a BitSetwhere
T: BitSetLike,
impl<'a, T> BitOr<T> for &'a BitSetwhere
T: BitSetLike,
source§impl<T> BitOr<T> for BitSetwhere
T: BitSetLike,
impl<T> BitOr<T> for BitSetwhere
T: BitSetLike,
source§impl BitSetLike for BitSet
impl BitSetLike for BitSet
source§fn layer3(&self) -> usize
fn layer3(&self) -> usize
Return a
usize
where each bit represents if any word in layer2
has been set.source§fn layer2(&self, i: usize) -> usize
fn layer2(&self, i: usize) -> usize
Return the
usize
from the array of usizes that indicates if any
bit has been set in layer1source§fn layer1(&self, i: usize) -> usize
fn layer1(&self, i: usize) -> usize
Return the
usize
from the array of usizes that indicates if any
bit has been set in layer0source§fn layer0(&self, i: usize) -> usize
fn layer0(&self, i: usize) -> usize
Return a
usize
that maps to the direct 1:1 association with
each index of the setsource§fn get_from_layer(&self, layer: usize, idx: usize) -> usize
fn get_from_layer(&self, layer: usize, idx: usize) -> usize
Gets the
usize
corresponding to layer and index. Read moresource§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns true if this
BitSetLike
contains nothing, and false otherwise.source§fn iter(self) -> BitIter<Self> ⓘwhere
Self: Sized,
fn iter(self) -> BitIter<Self> ⓘwhere
Self: Sized,
Create an iterator that will scan over the keyspace
source§fn par_iter(self) -> BitParIter<Self>where
Self: Sized,
fn par_iter(self) -> BitParIter<Self>where
Self: Sized,
Create a parallel iterator that will scan over the keyspace
source§impl<'a, T> BitXor<T> for &'a BitSetwhere
T: BitSetLike,
impl<'a, T> BitXor<T> for &'a BitSetwhere
T: BitSetLike,
source§impl<T> BitXor<T> for BitSetwhere
T: BitSetLike,
impl<T> BitXor<T> for BitSetwhere
T: BitSetLike,
source§impl DrainableBitSet for BitSet
impl DrainableBitSet for BitSet
source§impl<'a> Extend<&'a u32> for BitSet
impl<'a> Extend<&'a u32> for BitSet
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = &'a u32>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = &'a u32>,
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl Extend<u32> for BitSet
impl Extend<u32> for BitSet
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = u32>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = u32>,
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl<'a> FromIterator<&'a u32> for BitSet
impl<'a> FromIterator<&'a u32> for BitSet
source§impl FromIterator<u32> for BitSet
impl FromIterator<u32> for BitSet
source§impl<'a> IntoIterator for &'a BitSet
impl<'a> IntoIterator for &'a BitSet
source§impl IntoIterator for BitSet
impl IntoIterator for BitSet
source§impl PartialEq for BitSet
impl PartialEq for BitSet
impl Eq for BitSet
Auto Trait Implementations§
impl RefUnwindSafe for BitSet
impl Send for BitSet
impl Sync for BitSet
impl Unpin for BitSet
impl UnwindSafe for BitSet
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
Mutably borrows from an owned value. Read more