SparseBitMatrix: add `insert_all` and `add_all` methods
This commit is contained in:
parent
71fef95e76
commit
7c74518f50
|
@ -75,6 +75,13 @@ impl<C: Idx> BitVector<C> {
|
||||||
new_value != value
|
new_value != value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets all bits to true.
|
||||||
|
pub fn insert_all(&mut self) {
|
||||||
|
for data in &mut self.data {
|
||||||
|
*data = u128::max_value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if the bit has changed.
|
/// Returns true if the bit has changed.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn remove(&mut self, bit: C) -> bool {
|
pub fn remove(&mut self, bit: C) -> bool {
|
||||||
|
@ -359,6 +366,12 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
|
||||||
self.vector[into].merge(from)
|
self.vector[into].merge(from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add all bits to the given row.
|
||||||
|
pub fn add_all(&mut self, row: R) {
|
||||||
|
self.ensure_row(row);
|
||||||
|
self.vector[row].insert_all();
|
||||||
|
}
|
||||||
|
|
||||||
/// Number of elements in the matrix.
|
/// Number of elements in the matrix.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.vector.len()
|
self.vector.len()
|
||||||
|
|
Loading…
Reference in New Issue