Struct hibitset::AtomicBitSet
[−]
[src]
pub struct AtomicBitSet { /* fields omitted */ }
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.
Methods
impl AtomicBitSet
[src]
fn new() -> AtomicBitSet
[src]
Creates an empty AtomicBitSet
.
fn add_atomic(&self, id: u32) -> bool
[src]
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.
fn add(&mut self, id: u32) -> bool
[src]
Adds id
to the BitSet
. Returns true
if the value was
already in the set.
fn remove(&mut self, id: u32) -> bool
[src]
Removes id
from the set, returns true
if the value
was removed, and false
if the value was not set
to begin with.
fn contains(&self, id: u32) -> bool
[src]
Returns true
if id
is in the set.
fn clear(&mut self)
[src]
Clear all bits in the set
Trait Implementations
impl Debug for AtomicBitSet
[src]
impl BitSetLike for AtomicBitSet
[src]
fn layer3(&self) -> usize
[src]
Return a usize where each bit represents if any word in layer2 has been set. Read more
fn layer2(&self, i: usize) -> usize
[src]
Return the usize from the array of usizes that indicates if any bit has been set in layer1 Read more
fn layer1(&self, i: usize) -> usize
[src]
Return the usize from the array of usizes that indicates if any bit has been set in layer0 Read more
fn layer0(&self, i: usize) -> usize
[src]
Return a usize that maps to the direct 1:1 association with each index of the set Read more
fn iter(self) -> BitIter<Self> where
Self: Sized,
[src]
Self: Sized,
Create an iterator that will scan over the keyspace
fn par_iter(self) -> BitParIter<Self> where
Self: Sized,
[src]
Self: Sized,
Create a parallel iterator that will scan over the keyspace