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§
Sourcefn clear(&self)
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[..]));
Sourcefn insert(&self, index: T) -> Option<bool>
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);
Sourcefn remove(&self, index: T) -> Option<bool>
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);