Fix sparse intersect bug, add more sparse / dense tests
This commit is contained in:
parent
1c1603e0b5
commit
d73a169f93
@ -272,7 +272,7 @@ fn dense_sparse_intersect<T: Idx>(
|
|||||||
sparse: &SparseBitSet<T>,
|
sparse: &SparseBitSet<T>,
|
||||||
) -> (SparseBitSet<T>, bool) {
|
) -> (SparseBitSet<T>, bool) {
|
||||||
let mut sparse_copy = sparse.clone();
|
let mut sparse_copy = sparse.clone();
|
||||||
sparse_intersect(&mut sparse_copy, |el| !dense.contains(*el));
|
sparse_intersect(&mut sparse_copy, |el| dense.contains(*el));
|
||||||
let n = sparse_copy.len();
|
let n = sparse_copy.len();
|
||||||
(sparse_copy, n != dense.count())
|
(sparse_copy, n != dense.count())
|
||||||
}
|
}
|
||||||
|
@ -108,14 +108,25 @@ fn hybrid_bitset() {
|
|||||||
assert!(!sparse01358.union(&hybrid)); // no change
|
assert!(!sparse01358.union(&hybrid)); // no change
|
||||||
assert!(hybrid.union(&sparse01358));
|
assert!(hybrid.union(&sparse01358));
|
||||||
assert!(hybrid.superset(&sparse01358) && sparse01358.superset(&hybrid));
|
assert!(hybrid.superset(&sparse01358) && sparse01358.superset(&hybrid));
|
||||||
assert!(!dense10.union(&sparse01358));
|
|
||||||
assert!(!dense256.union(&dense10));
|
assert!(!dense256.union(&dense10));
|
||||||
|
|
||||||
|
// dense / sparse where dense superset sparse
|
||||||
|
assert!(!dense10.clone().union(&sparse01358));
|
||||||
|
assert!(sparse01358.clone().union(&dense10));
|
||||||
assert!(dense10.clone().intersect(&sparse01358));
|
assert!(dense10.clone().intersect(&sparse01358));
|
||||||
assert!(!sparse01358.clone().intersect(&dense10));
|
assert!(!sparse01358.clone().intersect(&dense10));
|
||||||
assert!(dense10.clone().subtract(&sparse01358));
|
assert!(dense10.clone().subtract(&sparse01358));
|
||||||
assert!(sparse01358.clone().subtract(&dense10));
|
assert!(sparse01358.clone().subtract(&dense10));
|
||||||
|
|
||||||
|
// dense / sparse where sparse superset dense
|
||||||
|
let dense038 = sparse038.to_dense();
|
||||||
|
assert!(!sparse0381.clone().union(&dense038));
|
||||||
|
assert!(dense038.clone().union(&sparse0381));
|
||||||
|
assert!(sparse0381.clone().intersect(&dense038));
|
||||||
|
assert!(!dense038.clone().intersect(&sparse0381));
|
||||||
|
assert!(sparse0381.clone().subtract(&dense038));
|
||||||
|
assert!(dense038.clone().subtract(&sparse0381));
|
||||||
|
|
||||||
let mut dense = dense10.clone();
|
let mut dense = dense10.clone();
|
||||||
assert!(dense.union(&dense256));
|
assert!(dense.union(&dense256));
|
||||||
assert!(dense.superset(&dense256) && dense256.superset(&dense));
|
assert!(dense.superset(&dense256) && dense256.superset(&dense));
|
||||||
|
Loading…
Reference in New Issue
Block a user