Skip to content

Commit 7c74518

Browse files
committed
SparseBitMatrix: add insert_all and add_all methods
1 parent 71fef95 commit 7c74518

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/librustc_data_structures/bitvec.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ impl<C: Idx> BitVector<C> {
7575
new_value != value
7676
}
7777

78+
/// Sets all bits to true.
79+
pub fn insert_all(&mut self) {
80+
for data in &mut self.data {
81+
*data = u128::max_value();
82+
}
83+
}
84+
7885
/// Returns true if the bit has changed.
7986
#[inline]
8087
pub fn remove(&mut self, bit: C) -> bool {
@@ -359,6 +366,12 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
359366
self.vector[into].merge(from)
360367
}
361368

369+
/// Add all bits to the given row.
370+
pub fn add_all(&mut self, row: R) {
371+
self.ensure_row(row);
372+
self.vector[row].insert_all();
373+
}
374+
362375
/// Number of elements in the matrix.
363376
pub fn len(&self) -> usize {
364377
self.vector.len()

0 commit comments

Comments
 (0)