Struct hibitset::AtomicBitSet
source · [−]pub struct AtomicBitSet { /* private fields */ }
Expand description
This is similar to a BitSet
but allows setting of value
without unique ownership of the structure
An AtomicBitSet
has the ability to add an item to the set
without unique ownership (given that the set is big enough).
Removing elements does require unique ownership as an effect
of the hierarchy it holds. Worst case multiple writers set the
same bit twice (but only is told they set it).
It is possible to atomically remove from the set, but not at the same time as atomically adding. This is because there is no way to know if layer 1-3 would be left in a consistent state if they are being cleared and set at the same time.
AtromicBitSet
resolves this race by disallowing atomic
clearing of bits.
Implementations
sourceimpl AtomicBitSet
impl AtomicBitSet
sourcepub fn new() -> AtomicBitSet
pub fn new() -> AtomicBitSet
Creates an empty AtomicBitSet
.
sourcepub fn add_atomic(&self, id: u32) -> bool
pub fn add_atomic(&self, id: u32) -> bool
Adds id
to the AtomicBitSet
. Returns true
if the value was
already in the set.
Because we cannot safely extend an AtomicBitSet without unique ownership this will panic if the Index is out of range.
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.
Trait Implementations
sourceimpl<'a, T> BitAnd<T> for &'a AtomicBitSet where
T: BitSetLike,
impl<'a, T> BitAnd<T> for &'a AtomicBitSet where
T: BitSetLike,
sourceimpl<T> BitAnd<T> for AtomicBitSet where
T: BitSetLike,
impl<T> BitAnd<T> for AtomicBitSet where
T: BitSetLike,
sourceimpl<'a, T> BitOr<T> for &'a AtomicBitSet where
T: BitSetLike,
impl<'a, T> BitOr<T> for &'a AtomicBitSet where
T: BitSetLike,
sourceimpl<T> BitOr<T> for AtomicBitSet where
T: BitSetLike,
impl<T> BitOr<T> for AtomicBitSet where
T: BitSetLike,
sourceimpl BitSetLike for AtomicBitSet
impl BitSetLike for AtomicBitSet
sourcefn layer3(&self) -> usize
fn layer3(&self) -> usize
Return a usize
where each bit represents if any word in layer2
has been set. Read more
sourcefn 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 layer1 Read more
sourcefn 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 layer0 Read more
sourcefn 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 set Read more
sourcefn 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 more
sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns true if this BitSetLike
contains nothing, and false otherwise.
sourcefn iter(self) -> BitIter<Self>ⓘNotable traits for BitIter<T>impl<T> Iterator for BitIter<T> where
T: BitSetLike, type Item = u32;
where
Self: Sized,
fn iter(self) -> BitIter<Self>ⓘNotable traits for BitIter<T>impl<T> Iterator for BitIter<T> where
T: BitSetLike, type Item = u32;
where
Self: Sized,
T: BitSetLike, type Item = u32;
Create an iterator that will scan over the keyspace
sourcefn 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
sourceimpl<'a, T> BitXor<T> for &'a AtomicBitSet where
T: BitSetLike,
impl<'a, T> BitXor<T> for &'a AtomicBitSet where
T: BitSetLike,
sourceimpl<T> BitXor<T> for AtomicBitSet where
T: BitSetLike,
impl<T> BitXor<T> for AtomicBitSet where
T: BitSetLike,
sourceimpl Debug for AtomicBitSet
impl Debug for AtomicBitSet
sourceimpl Default for AtomicBitSet
impl Default for AtomicBitSet
sourceimpl DrainableBitSet for AtomicBitSet
impl DrainableBitSet for AtomicBitSet
sourcefn drain<'a>(&'a mut self) -> DrainBitIter<'a, Self>ⓘNotable traits for DrainBitIter<'a, T>impl<'a, T> Iterator for DrainBitIter<'a, T> where
T: DrainableBitSet, type Item = u32;
where
Self: Sized,
fn drain<'a>(&'a mut self) -> DrainBitIter<'a, Self>ⓘNotable traits for DrainBitIter<'a, T>impl<'a, T> Iterator for DrainBitIter<'a, T> where
T: DrainableBitSet, type Item = u32;
where
Self: Sized,
T: DrainableBitSet, type Item = u32;
Create a draining iterator that will scan over the keyspace and clears it while doing so.
sourceimpl<'a> Extend<&'a u32> for AtomicBitSet
impl<'a> Extend<&'a u32> for AtomicBitSet
sourcefn 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
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl Extend<u32> for AtomicBitSet
impl Extend<u32> for AtomicBitSet
sourcefn 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
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<'a> FromIterator<&'a u32> for AtomicBitSet
impl<'a> FromIterator<&'a u32> for AtomicBitSet
sourcefn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = &'a u32>,
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = &'a u32>,
Creates a value from an iterator. Read more
sourceimpl FromIterator<u32> for AtomicBitSet
impl FromIterator<u32> for AtomicBitSet
sourcefn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = u32>,
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = u32>,
Creates a value from an iterator. Read more
sourceimpl<'a> IntoIterator for &'a AtomicBitSet
impl<'a> IntoIterator for &'a AtomicBitSet
sourceimpl IntoIterator for AtomicBitSet
impl IntoIterator for AtomicBitSet
sourceimpl<'a> Not for &'a AtomicBitSet
impl<'a> Not for &'a AtomicBitSet
sourceimpl Not for AtomicBitSet
impl Not for AtomicBitSet
Auto Trait Implementations
impl RefUnwindSafe for AtomicBitSet
impl Send for AtomicBitSet
impl Sync for AtomicBitSet
impl Unpin for AtomicBitSet
impl UnwindSafe for AtomicBitSet
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more