Remove some unused bitset code.
This commit is contained in:
@@ -973,48 +973,6 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Idx> BitRelations<ChunkedBitSet<T>> for DenseBitSet<T> {
|
||||
fn union(&mut self, other: &ChunkedBitSet<T>) -> bool {
|
||||
sequential_update(|elem| self.insert(elem), other.iter())
|
||||
}
|
||||
|
||||
fn subtract(&mut self, _other: &ChunkedBitSet<T>) -> bool {
|
||||
unimplemented!("implement if/when necessary");
|
||||
}
|
||||
|
||||
fn intersect(&mut self, other: &ChunkedBitSet<T>) -> bool {
|
||||
assert_eq!(self.domain_size(), other.domain_size);
|
||||
let mut changed = false;
|
||||
for (i, chunk) in other.chunks.iter().enumerate() {
|
||||
let mut words = &mut self.words[i * CHUNK_WORDS..];
|
||||
if words.len() > CHUNK_WORDS {
|
||||
words = &mut words[..CHUNK_WORDS];
|
||||
}
|
||||
match chunk {
|
||||
Zeros => {
|
||||
for word in words {
|
||||
if *word != 0 {
|
||||
changed = true;
|
||||
*word = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ones => (),
|
||||
Mixed(_, data) => {
|
||||
for (i, word) in words.iter_mut().enumerate() {
|
||||
let new_val = *word & data[i];
|
||||
if new_val != *word {
|
||||
changed = true;
|
||||
*word = new_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
changed
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Clone for ChunkedBitSet<T> {
|
||||
fn clone(&self) -> Self {
|
||||
ChunkedBitSet {
|
||||
@@ -1125,15 +1083,6 @@ enum ChunkIter<'a> {
|
||||
Finished,
|
||||
}
|
||||
|
||||
// Applies a function to mutate a bitset, and returns true if any
|
||||
// of the applications return true
|
||||
fn sequential_update<T: Idx>(
|
||||
mut self_update: impl FnMut(T) -> bool,
|
||||
it: impl Iterator<Item = T>,
|
||||
) -> bool {
|
||||
it.fold(false, |changed, elem| self_update(elem) | changed)
|
||||
}
|
||||
|
||||
impl<T: Idx> fmt::Debug for ChunkedBitSet<T> {
|
||||
fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
w.debug_list().entries(self.iter()).finish()
|
||||
|
||||
@@ -306,34 +306,6 @@ fn with_elements_chunked(elements: &[usize], domain_size: usize) -> ChunkedBitSe
|
||||
s
|
||||
}
|
||||
|
||||
fn with_elements_standard(elements: &[usize], domain_size: usize) -> DenseBitSet<usize> {
|
||||
let mut s = DenseBitSet::new_empty(domain_size);
|
||||
for &e in elements {
|
||||
assert!(s.insert(e));
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chunked_bitset_into_bitset_operations() {
|
||||
let a = vec![1, 5, 7, 11, 15, 2000, 3000];
|
||||
let b = vec![3, 4, 11, 3000, 4000];
|
||||
let aub = vec![1, 3, 4, 5, 7, 11, 15, 2000, 3000, 4000];
|
||||
let aib = vec![11, 3000];
|
||||
|
||||
let b = with_elements_chunked(&b, 9876);
|
||||
|
||||
let mut union = with_elements_standard(&a, 9876);
|
||||
assert!(union.union(&b));
|
||||
assert!(!union.union(&b));
|
||||
assert!(union.iter().eq(aub.iter().copied()));
|
||||
|
||||
let mut intersection = with_elements_standard(&a, 9876);
|
||||
assert!(intersection.intersect(&b));
|
||||
assert!(!intersection.intersect(&b));
|
||||
assert!(intersection.iter().eq(aib.iter().copied()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chunked_bitset_iter() {
|
||||
fn check_iter(bit: &ChunkedBitSet<usize>, vec: &Vec<usize>) {
|
||||
|
||||
Reference in New Issue
Block a user