[−][src]Struct hibitset::AtomicBitSet
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]
pub fn new() -> AtomicBitSet
[src]
Creates an empty AtomicBitSet
.
pub 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.
pub fn add(&mut self, id: u32) -> bool
[src]
Adds id
to the BitSet
. Returns true
if the value was
already in the set.
pub 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.
pub fn contains(&self, id: u32) -> bool
[src]
Returns true
if id
is in the set.
pub fn clear(&mut self)
[src]
Clear all bits in the set
Trait Implementations
impl BitSetLike for AtomicBitSet
[src]
fn layer3(&self) -> usize
[src]
fn layer2(&self, i: usize) -> usize
[src]
fn layer1(&self, i: usize) -> usize
[src]
fn layer0(&self, i: usize) -> usize
[src]
fn contains(&self, i: u32) -> bool
[src]
fn get_from_layer(&self, layer: usize, idx: usize) -> usize
[src]
Gets the usize
corresponding to layer and index. Read more
fn is_empty(&self) -> bool
[src]
Returns true if this BitSetLike
contains nothing, and false otherwise.
ⓘImportant traits for BitIter<T>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
impl DrainableBitSet for AtomicBitSet
[src]
fn remove(&mut self, i: u32) -> bool
[src]
ⓘImportant traits for DrainBitIter<'a, T>fn drain<'a>(&'a mut self) -> DrainBitIter<'a, Self> where
Self: Sized,
[src]
Self: Sized,
Create a draining iterator that will scan over the keyspace and clears it while doing so.
impl IntoIterator for AtomicBitSet
[src]
type Item = <BitIter<Self> as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = BitIter<Self>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a> IntoIterator for &'a AtomicBitSet
[src]
type Item = <BitIter<Self> as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = BitIter<Self>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl Default for AtomicBitSet
[src]
impl Extend<u32> for AtomicBitSet
[src]
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = u32>,
[src]
T: IntoIterator<Item = u32>,
impl<'a> Extend<&'a u32> for AtomicBitSet
[src]
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = &'a u32>,
[src]
T: IntoIterator<Item = &'a u32>,
impl Debug for AtomicBitSet
[src]
impl Not for AtomicBitSet
[src]
type Output = BitSetNot<Self>
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
impl<'a> Not for &'a AtomicBitSet
[src]
type Output = BitSetNot<Self>
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
impl<T> BitAnd<T> for AtomicBitSet where
T: BitSetLike,
[src]
T: BitSetLike,
type Output = BitSetAnd<Self, T>
The resulting type after applying the &
operator.
fn bitand(self, rhs: T) -> Self::Output
[src]
impl<'a, T> BitAnd<T> for &'a AtomicBitSet where
T: BitSetLike,
[src]
T: BitSetLike,
type Output = BitSetAnd<Self, T>
The resulting type after applying the &
operator.
fn bitand(self, rhs: T) -> Self::Output
[src]
impl<T> BitOr<T> for AtomicBitSet where
T: BitSetLike,
[src]
T: BitSetLike,
type Output = BitSetOr<Self, T>
The resulting type after applying the |
operator.
fn bitor(self, rhs: T) -> Self::Output
[src]
impl<'a, T> BitOr<T> for &'a AtomicBitSet where
T: BitSetLike,
[src]
T: BitSetLike,
type Output = BitSetOr<Self, T>
The resulting type after applying the |
operator.
fn bitor(self, rhs: T) -> Self::Output
[src]
impl<T> BitXor<T> for AtomicBitSet where
T: BitSetLike,
[src]
T: BitSetLike,
type Output = BitSetXor<Self, T>
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: T) -> Self::Output
[src]
impl<'a, T> BitXor<T> for &'a AtomicBitSet where
T: BitSetLike,
[src]
T: BitSetLike,
type Output = BitSetXor<Self, T>
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: T) -> Self::Output
[src]
impl FromIterator<u32> for AtomicBitSet
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = u32>,
[src]
T: IntoIterator<Item = u32>,
impl<'a> FromIterator<&'a u32> for AtomicBitSet
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = &'a u32>,
[src]
T: IntoIterator<Item = &'a u32>,
Auto Trait Implementations
impl Unpin for AtomicBitSet
impl Sync for AtomicBitSet
impl Send for AtomicBitSet
impl UnwindSafe for AtomicBitSet
impl RefUnwindSafe for AtomicBitSet
Blanket Implementations
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,