mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Addd missing domain size assertions
This commit is contained in:
parent
c7357270b8
commit
86bd551e4c
@ -289,6 +289,7 @@ fn dense_sparse_intersect<T: Idx>(
|
|||||||
// hybrid REL dense
|
// hybrid REL dense
|
||||||
impl<T: Idx> BitRelations<BitSet<T>> for HybridBitSet<T> {
|
impl<T: Idx> BitRelations<BitSet<T>> for HybridBitSet<T> {
|
||||||
fn union(&mut self, other: &BitSet<T>) -> bool {
|
fn union(&mut self, other: &BitSet<T>) -> bool {
|
||||||
|
assert_eq!(self.domain_size(), other.domain_size);
|
||||||
match self {
|
match self {
|
||||||
HybridBitSet::Sparse(sparse) => {
|
HybridBitSet::Sparse(sparse) => {
|
||||||
// `self` is sparse and `other` is dense. To
|
// `self` is sparse and `other` is dense. To
|
||||||
@ -316,6 +317,7 @@ impl<T: Idx> BitRelations<BitSet<T>> for HybridBitSet<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn subtract(&mut self, other: &BitSet<T>) -> bool {
|
fn subtract(&mut self, other: &BitSet<T>) -> bool {
|
||||||
|
assert_eq!(self.domain_size(), other.domain_size);
|
||||||
match self {
|
match self {
|
||||||
HybridBitSet::Sparse(sparse) => {
|
HybridBitSet::Sparse(sparse) => {
|
||||||
sequential_update(|elem| sparse.remove(elem), other.iter())
|
sequential_update(|elem| sparse.remove(elem), other.iter())
|
||||||
@ -325,6 +327,7 @@ impl<T: Idx> BitRelations<BitSet<T>> for HybridBitSet<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn intersect(&mut self, other: &BitSet<T>) -> bool {
|
fn intersect(&mut self, other: &BitSet<T>) -> bool {
|
||||||
|
assert_eq!(self.domain_size(), other.domain_size);
|
||||||
match self {
|
match self {
|
||||||
HybridBitSet::Sparse(sparse) => sparse_intersect(sparse, |elem| other.contains(*elem)),
|
HybridBitSet::Sparse(sparse) => sparse_intersect(sparse, |elem| other.contains(*elem)),
|
||||||
HybridBitSet::Dense(dense) => dense.intersect(other),
|
HybridBitSet::Dense(dense) => dense.intersect(other),
|
||||||
@ -385,7 +388,6 @@ impl<T: Idx> BitRelations<HybridBitSet<T>> for HybridBitSet<T> {
|
|||||||
// Both sets are sparse. Add the elements in
|
// Both sets are sparse. Add the elements in
|
||||||
// `other_sparse` to `self` one at a time. This
|
// `other_sparse` to `self` one at a time. This
|
||||||
// may or may not cause `self` to be densified.
|
// may or may not cause `self` to be densified.
|
||||||
assert_eq!(self.domain_size(), other.domain_size());
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for elem in other_sparse.iter() {
|
for elem in other_sparse.iter() {
|
||||||
changed |= self.insert(*elem);
|
changed |= self.insert(*elem);
|
||||||
|
Loading…
Reference in New Issue
Block a user