about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-07-23 18:13:54 +0300
committerNiko Matsakis <niko@alum.mit.edu>2018-07-25 06:38:20 +0300
commit7c74518f504737b6a35a892156cf42e578073eac (patch)
tree5fd8140fa0b2268d63cdd609312e8e23bfd24d60 /src/librustc_data_structures
parent71fef95e765f812f2eada304f1a6be00a814c0e9 (diff)
downloadrust-7c74518f504737b6a35a892156cf42e578073eac.tar.gz
rust-7c74518f504737b6a35a892156cf42e578073eac.zip
SparseBitMatrix: add `insert_all` and `add_all` methods
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/bitvec.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/librustc_data_structures/bitvec.rs b/src/librustc_data_structures/bitvec.rs
index f564f46dd2b..245f5d61099 100644
--- a/src/librustc_data_structures/bitvec.rs
+++ b/src/librustc_data_structures/bitvec.rs
@@ -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()