Skip to main content

AtomicBitSet

Struct AtomicBitSet 

Source
pub struct AtomicBitSet<A, V>(/* private fields */);
Expand description

Atomic bitset backed by a single atomic primitive or a fixed-size array of atomics.

§Atomicity guarantees

For single-primitive stores (e.g. AtomicBitSet<AtomicU64, V>), each method operates on one atomic word — all operations are truly atomic with respect to the entire bitset.

For multi-word stores (e.g. AtomicBitSet<[AtomicU64; 4], V>), each individual operation (insert, remove, contains, …) is atomic per word, but the bitset as a whole is not a single atomic unit. Concurrent modifications to bits in the same word are correctly synchronized. Modifications to bits in different words are independent atomic operations with no cross-word transactional guarantee. Composite queries like len(), iter(), or is_subset() may observe a mix of old and new state across words under concurrent mutation.

Implementations§

Source§

impl<A: AtomicPrimStore, V> AtomicBitSet<A, V>

Source

pub const fn new() -> Self

Source

pub const fn empty() -> Self

Source

pub fn from_element(elem: V) -> Self
where V: AsPrimitive<usize>, A::Item: PrimInt + BitOps,

Source

pub fn from_bits(bits: A) -> Self

Source

pub fn into_bits(self) -> A

Source

pub fn len(&self) -> usize
where A::Item: PrimInt,

Source

pub fn is_empty(&self) -> bool
where A::Item: PrimInt,

Source

pub fn first(&self) -> Option<V>
where V: TryFrom<u8>, A::Item: PrimInt,

Source

pub fn last(&self) -> Option<V>
where V: TryFrom<u8>, A::Item: PrimInt,

Source

pub fn pop_first(&self) -> Option<V>
where V: TryFrom<u8>, A::Item: PrimInt + BitOps,

Source

pub fn pop_last(&self) -> Option<V>
where V: TryFrom<u8>, A::Item: PrimInt + BitOps,

Source

pub fn contains(&self, id: &V) -> bool
where V: Copy + AsPrimitive<usize>, A::Item: PrimInt,

Source

pub fn set(&self, id: V, value: bool)
where V: AsPrimitive<usize>, A::Item: PrimInt + BitOps,

Source

pub fn insert(&self, id: V) -> bool
where V: AsPrimitive<usize>, A::Item: PrimInt + BitOps,

Source

pub fn remove(&self, id: V) -> bool
where V: AsPrimitive<usize>, A::Item: PrimInt + BitOps,

Source

pub fn toggle(&self, id: V)
where V: AsPrimitive<usize>, A::Item: PrimInt + BitOps,

Source

pub fn clear(&self)
where A::Item: PrimInt,

Source

pub fn retain(&self, f: impl FnMut(V) -> bool)
where V: TryFrom<u8>, A::Item: PrimInt + BitOps,

Source

pub fn union(&self, other: A::Item) -> BitSet<A::Item, V>
where A::Item: PrimInt + PrimStore,

Source

pub fn difference(&self, other: A::Item) -> BitSet<A::Item, V>
where A::Item: PrimInt + PrimStore,

Source

pub fn includes(&self, other: A::Item) -> bool
where A::Item: PrimInt,

Source

pub fn iter(&self) -> PrimBitSetIter<A::Item, V>
where A::Item: PrimInt,

Source

pub fn load_store(&self) -> A::Item
where A::Item: Clone,

Source

pub fn swap_store(&self, store: &mut A::Item)
where A::Item: Copy,

Source

pub fn union_from(&self, other: A::Item)
where A::Item: Copy + BitOps,

Source

pub fn drain(&self) -> PrimBitSetIter<A::Item, V>
where A::Item: Copy + PrimInt + Zero,

Source

pub fn is_subset(&self, other: &Self) -> bool
where A::Item: PrimInt,

Source

pub fn is_superset(&self, other: &Self) -> bool
where A::Item: PrimInt,

Source

pub fn is_disjoint(&self, other: &Self) -> bool
where A::Item: PrimInt,

Source§

impl<A: Radium, V, const N: usize> AtomicBitSet<[A; N], V>

Source

pub const fn new() -> Self

Source

pub const fn empty() -> Self

Source

pub fn from_bits(raw: [A; N]) -> Self

Source

pub fn from_element(id: V) -> Self
where V: AsPrimitive<usize>, A::Item: PrimInt + BitOps,

Source

pub fn into_bits(self) -> [A; N]

Source

pub fn union_from(&self, other: &BitSet<[<A as Radium>::Item; N], V>)
where <A as Radium>::Item: BitOps + Copy + PrimStore,

Source

pub fn drain(&self) -> BitSet<[<A as Radium>::Item; N], V>
where <A as Radium>::Item: Copy + PrimInt + PrimStore,

Methods from Deref<Target = AtomicBitSlice<A, V>>§

Source

pub fn as_raw_slice(&self) -> &[A]

Source

pub fn capacity(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn first(&self) -> Option<V>
where V: TryFrom<usize>,

Source

pub fn last(&self) -> Option<V>
where V: TryFrom<usize>,

Source

pub fn pop_first(&self) -> Option<V>
where V: TryFrom<usize>, A::Item: BitOps,

Source

pub fn pop_last(&self) -> Option<V>
where V: TryFrom<usize>, A::Item: BitOps,

Source

pub fn contains(&self, id: &V) -> bool
where V: Copy + AsPrimitive<usize>,

Source

pub fn insert(&self, id: V) -> bool
where V: AsPrimitive<usize>, A::Item: BitOps,

Source

pub fn remove(&self, id: V) -> bool
where V: AsPrimitive<usize>, A::Item: BitOps,

Source

pub fn set(&self, id: V, value: bool)
where V: AsPrimitive<usize>, A::Item: BitOps,

Source

pub fn toggle(&self, id: V)
where V: AsPrimitive<usize>, A::Item: BitOps,

Source

pub fn clear(&self)

Source

pub fn retain(&self, f: impl FnMut(V) -> bool)
where V: TryFrom<usize>, A::Item: BitOps,

Source

pub fn iter(&self) -> impl Iterator<Item = V> + '_
where A::Item: BitAndAssign, V: TryFrom<usize>,

Source

pub fn is_subset(&self, other: &Self) -> bool

Source

pub fn is_superset(&self, other: &Self) -> bool

Source

pub fn is_disjoint(&self, other: &Self) -> bool

Source

pub fn union_from(&self, other: &[A::Item])
where A::Item: BitOps + Copy,

Trait Implementations§

Source§

impl<A: AtomicPrimStore, V> Binary for AtomicBitSet<A, V>
where A::Item: PrimInt + Binary,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: Radium, V, const N: usize> Debug for AtomicBitSet<[A; N], V>
where A::Item: PrimInt,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: AtomicPrimStore, V> Debug for AtomicBitSet<A, V>
where A::Item: PrimInt,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: Radium, V, const N: usize> Default for AtomicBitSet<[A; N], V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<A: AtomicPrimStore, V> Default for AtomicBitSet<A, V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<A: Radium, V, const N: usize> Deref for AtomicBitSet<[A; N], V>
where A::Item: PrimInt,

Source§

type Target = AtomicBitSlice<A, V>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<A: AtomicPrimStore, V> LowerHex for AtomicBitSet<A, V>
where A::Item: PrimInt + LowerHex,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: AtomicPrimStore, V> Octal for AtomicBitSet<A, V>
where A::Item: PrimInt + Octal,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: AtomicPrimStore, V> UpperHex for AtomicBitSet<A, V>
where A::Item: PrimInt + UpperHex,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A, V> Freeze for AtomicBitSet<A, V>
where A: Freeze,

§

impl<A, V> RefUnwindSafe for AtomicBitSet<A, V>

§

impl<A, V> Send for AtomicBitSet<A, V>
where A: Send, V: Send,

§

impl<A, V> Sync for AtomicBitSet<A, V>
where A: Sync, V: Sync,

§

impl<A, V> Unpin for AtomicBitSet<A, V>
where A: Unpin, V: Unpin,

§

impl<A, V> UnsafeUnpin for AtomicBitSet<A, V>
where A: UnsafeUnpin,

§

impl<A, V> UnwindSafe for AtomicBitSet<A, V>
where A: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.