Trait SharedBitSet

Source
pub trait SharedBitSet<T> {
    // Required methods
    fn clear(&self);
    fn insert(&self, index: T) -> Option<bool>;
    fn remove(&self, index: T) -> Option<bool>;
}
Expand description

A trait for updating values in a shared bit-set.

Required Methods§

Source

fn clear(&self)

Clears the set

§Example
use index_set::{SharedBitSet, BitSet};
use std::sync::atomic::AtomicU32;

let mut bitset: [AtomicU32; 4] = Default::default();
bitset.insert(0);
assert!(!BitSet::is_empty(&bitset[..]));

bitset.clear();
assert!(BitSet::is_empty(&bitset[..]));
Source

fn insert(&self, index: T) -> Option<bool>

Inserts the index into the set Returns true if the index was not already set

§Example
use index_set::{SharedBitSet, BitSet};
use std::sync::atomic::AtomicU32;

let mut bitset: [AtomicU32; 4] = Default::default();
bitset.insert(0);
assert_eq!(bitset.has(0), true);
Source

fn remove(&self, index: T) -> Option<bool>

Removes the index from the set Returns true if the index was set.

§Example
use index_set::{SharedBitSet, BitSet};
use std::sync::atomic::AtomicU32;

let mut bitset: [AtomicU32; 4] = Default::default();
bitset.insert(42);
assert_eq!(bitset.has(42), true);

bitset.remove(42);
assert_eq!(bitset.has(42), false);

Implementations on Foreign Types§

Source§

impl SharedBitSet<u32> for [AtomicU32]

Source§

fn clear(&self)

Source§

fn insert(&self, index: u32) -> Option<bool>

Source§

fn remove(&self, index: u32) -> Option<bool>

Source§

impl SharedBitSet<u64> for [AtomicU64]

Source§

fn clear(&self)

Source§

fn insert(&self, index: u64) -> Option<bool>

Source§

fn remove(&self, index: u64) -> Option<bool>

Source§

impl SharedBitSet<usize> for [AtomicUsize]

Source§

fn clear(&self)

Source§

fn insert(&self, index: usize) -> Option<bool>

Source§

fn remove(&self, index: usize) -> Option<bool>

Source§

impl<Set, T> SharedBitSet<T> for &Set
where Set: SharedBitSet<T> + ?Sized,

Source§

fn clear(&self)

Source§

fn insert(&self, index: T) -> Option<bool>

Source§

fn remove(&self, index: T) -> Option<bool>

Implementors§