From 7c74518f504737b6a35a892156cf42e578073eac Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 23 Jul 2018 18:13:54 +0300 Subject: [PATCH] SparseBitMatrix: add `insert_all` and `add_all` methods --- src/librustc_data_structures/bitvec.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 BitVector { 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 SparseBitMatrix { 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()