SparseBitMatrix: add `insert_all` and `add_all` methods

This commit is contained in:
Niko Matsakis 2018-07-23 18:13:54 +03:00
parent 71fef95e76
commit 7c74518f50
1 changed files with 13 additions and 0 deletions

View File

@ -75,6 +75,13 @@ impl<C: Idx> BitVector<C> {
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.
#[inline]
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)
}
/// 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.
pub fn len(&self) -> usize {
self.vector.len()