pub enum IndexSet {
Small(u32),
Medium(u64),
Large(u128),
Heap(Vec<u64>),
}Expand description
A compact bitset for tracking slot indices in CSE.
Uses stack-optimized representations for small sizes (up to 32, 64, and 128
bits) and falls back to a heap-allocated Vec<u64> for larger sets.
Variants§
Small(u32)
Up to 32 bits stored inline.
Medium(u64)
33–64 bits stored inline.
Large(u128)
65–128 bits stored inline.
Heap(Vec<u64>)
More than 128 bits, stored as a heap-allocated vector of 64-bit chunks.
Implementations§
Source§impl IndexSet
impl IndexSet
Sourcepub fn singleton(slot: usize) -> Self
pub fn singleton(slot: usize) -> Self
Create a set containing exactly one slot index.
§Examples
let s = IndexSet::singleton(5);
assert!(s.contains(5));
assert!(!s.contains(4));Sourcepub fn insert(&mut self, slot: usize, value: bool)
pub fn insert(&mut self, slot: usize, value: bool)
Insert or remove a slot index.
Automatically promotes the representation when the slot exceeds the current variant’s capacity.
§Examples
let mut s = IndexSet::default();
s.insert(1, true);
assert!(s.contains(1));
s.insert(1, false);
assert!(!s.contains(1));Sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> bool
Returns true if the two sets have no elements in common.
§Examples
let a = IndexSet::singleton(0);
let b = IndexSet::singleton(1);
assert!(a.is_disjoint(&b));
let c = IndexSet::singleton(0);
assert!(!a.is_disjoint(&c));Sourcepub fn contains(&self, slot: usize) -> bool
pub fn contains(&self, slot: usize) -> bool
Returns true if the given slot index is present in the set.
§Examples
let s = IndexSet::singleton(3);
assert!(s.contains(3));
assert!(!s.contains(0));Sourcepub fn iter(&self) -> IndexSetIter<'_> ⓘ
pub fn iter(&self) -> IndexSetIter<'_> ⓘ
Iterate over all slot indices present in the set, in ascending order.
§Examples
let mut s = IndexSet::singleton(2);
s.insert(5, true);
let slots: Vec<usize> = s.iter().collect();
assert_eq!(slots, vec![2, 5]);Sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Returns the number of slot indices in the set (population count).
§Examples
let mut s = IndexSet::singleton(0);
s.insert(2, true);
s.insert(5, true);
assert_eq!(s.count_ones(), 3);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the set contains no elements.
§Examples
let mut s: IndexSet = Default::default();
assert!(s.is_empty());
s.insert(0, true);
assert!(!s.is_empty());Trait Implementations§
Source§impl BitAndAssign for IndexSet
impl BitAndAssign for IndexSet
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOrAssign for IndexSet
impl BitOrAssign for IndexSet
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreimpl Eq for IndexSet
Source§impl From<ArithIndexSet> for IndexSet
impl From<ArithIndexSet> for IndexSet
Source§fn from(set: ArithIndexSet) -> Self
fn from(set: ArithIndexSet) -> Self
Source§impl From<IndexSet> for ArithIndexSet
impl From<IndexSet> for ArithIndexSet
Source§impl<'a> IntoIterator for &'a IndexSet
impl<'a> IntoIterator for &'a IndexSet
Source§impl Ord for IndexSet
impl Ord for IndexSet
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for IndexSet
impl PartialOrd for IndexSet
Source§impl ShlAssign<usize> for IndexSet
impl ShlAssign<usize> for IndexSet
Source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<= operation. Read more