honeycomb_core/cmap/components/
unused.rs1use std::{
2 ops::{Index, IndexMut},
3 slice::Iter,
4};
5
6use crate::stm::TVar;
7
8use super::identifiers::DartIdType;
9
10pub struct UnusedDarts(Vec<TVar<bool>>);
12
13#[allow(unused)]
14impl UnusedDarts {
15 pub fn new(n_darts: usize) -> Self {
17 Self((0..n_darts).map(|_| TVar::new(false)).collect())
18 }
19
20 pub fn extend(&mut self, len: usize) {
22 self.0.extend((0..len).map(|_| TVar::new(false)));
23 }
24
25 pub fn len(&self) -> usize {
27 self.0.len()
28 }
29
30 pub fn iter(&self) -> Iter<'_, TVar<bool>> {
31 self.0.iter()
32 }
33}
34
35impl Index<DartIdType> for UnusedDarts {
36 type Output = TVar<bool>;
37
38 fn index(&self, dart_id: DartIdType) -> &Self::Output {
39 &self.0[dart_id as usize]
40 }
41}
42
43impl IndexMut<DartIdType> for UnusedDarts {
44 fn index_mut(&mut self, dart_id: DartIdType) -> &mut Self::Output {
45 &mut self.0[dart_id as usize]
46 }
47}