indexical/bitset/
bitvec.rsuse bitvec::{prelude::Lsb0, slice::IterOnes};
use crate::{
bitset::BitSet,
pointer::{ArcFamily, RcFamily, RefFamily},
};
pub use ::bitvec::{self, vec::BitVec};
impl BitSet for BitVec {
type Iter<'a> = IterOnes<'a, usize, Lsb0>;
fn empty(size: usize) -> Self {
bitvec::bitvec![usize, Lsb0; 0; size]
}
fn contains(&self, index: usize) -> bool {
self[index]
}
fn insert(&mut self, index: usize) -> bool {
let contained = self[index];
self.set(index, true);
!contained
}
fn iter(&self) -> Self::Iter<'_> {
self.iter_ones()
}
fn len(&self) -> usize {
self.count_ones()
}
fn union(&mut self, other: &Self) {
*self |= other;
}
fn intersect(&mut self, other: &Self) {
*self &= other;
}
fn invert(&mut self) {
take_mut::take(self, |this| !this)
}
fn clear(&mut self) {
self.clear();
}
fn subtract(&mut self, other: &Self) {
let mut other_copy = other.clone();
other_copy.invert();
self.intersect(&other_copy);
}
fn insert_all(&mut self) {
self.fill(true);
}
fn copy_from(&mut self, other: &Self) {
self.copy_from_bitslice(other);
}
}
pub type IndexSet<T> = crate::IndexSet<'static, T, BitVec, RcFamily>;
pub type ArcIndexSet<'a, T> = crate::IndexSet<'a, T, BitVec, ArcFamily>;
pub type RefIndexSet<'a, T> = crate::IndexSet<'a, T, BitVec, RefFamily<'a>>;
pub type IndexMatrix<R, C> = crate::IndexMatrix<'static, R, C, BitVec, RcFamily>;
pub type ArcIndexMatrix<R, C> = crate::IndexMatrix<'static, R, C, BitVec, ArcFamily>;
pub type RefIndexMatrix<'a, R, C> = crate::IndexMatrix<'a, R, C, BitVec, RefFamily<'a>>;
#[test]
fn test_bitvec() {
crate::test_utils::impl_test::<BitVec>();
}