]> git.lizzy.rs Git - rust.git/commitdiff
SparseBitMatrix: add `insert_all` and `add_all` methods
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 23 Jul 2018 15:13:54 +0000 (18:13 +0300)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 25 Jul 2018 03:38:20 +0000 (06:38 +0300)
src/librustc_data_structures/bitvec.rs

index f564f46dd2b3f36e4486a9e267d27145e63fa820..245f5d610994aecb03eb653b682722fc12b25b81 100644 (file)
@@ -75,6 +75,13 @@ pub fn insert(&mut self, bit: C) -> bool {
         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 @@ pub fn merge_into(&mut self, into: R, from: &BitVector<C>) -> bool {
         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()