@@ -453,6 +453,11 @@ impl<T: Idx> ChunkedBitSet<T> {
453453 ChunkedBitSet :: new ( domain_size, /* is_empty */ false )
454454 }
455455
456+ pub fn clear ( & mut self ) {
457+ let domain_size = self . domain_size ( ) ;
458+ * self = ChunkedBitSet :: new_empty ( domain_size) ;
459+ }
460+
456461 #[ cfg( test) ]
457462 fn chunks ( & self ) -> & [ Chunk ] {
458463 & self . chunks
@@ -1883,7 +1888,7 @@ impl<R: Idx, C: Idx> fmt::Debug for BitMatrix<R, C> {
18831888/// sparse representation.
18841889///
18851890/// Initially, every row has no explicit representation. If any bit within a
1886- /// row is set, the entire row is instantiated as `Some(<HybridBitSet >)`.
1891+ /// row is set, the entire row is instantiated as `Some(<ChunkedBitSet >)`.
18871892/// Furthermore, any previously uninstantiated rows prior to it will be
18881893/// instantiated as `None`. Those prior rows may themselves become fully
18891894/// instantiated later on if any of their bits are set.
@@ -1897,7 +1902,7 @@ where
18971902 C : Idx ,
18981903{
18991904 num_columns : usize ,
1900- rows : IndexVec < R , Option < HybridBitSet < C > > > ,
1905+ rows : IndexVec < R , Option < ChunkedBitSet < C > > > ,
19011906}
19021907
19031908impl < R : Idx , C : Idx > SparseBitMatrix < R , C > {
@@ -1906,10 +1911,10 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
19061911 Self { num_columns, rows : IndexVec :: new ( ) }
19071912 }
19081913
1909- fn ensure_row ( & mut self , row : R ) -> & mut HybridBitSet < C > {
1910- // Instantiate any missing rows up to and including row `row` with an empty HybridBitSet .
1911- // Then replace row `row` with a full HybridBitSet if necessary.
1912- self . rows . get_or_insert_with ( row, || HybridBitSet :: new_empty ( self . num_columns ) )
1914+ fn ensure_row ( & mut self , row : R ) -> & mut ChunkedBitSet < C > {
1915+ // Instantiate any missing rows up to and including row `row` with an empty ChunkedBitSet .
1916+ // Then replace row `row` with a full ChunkedBitSet if necessary.
1917+ self . rows . get_or_insert_with ( row, || ChunkedBitSet :: new_empty ( self . num_columns ) )
19131918 }
19141919
19151920 /// Sets the cell at `(row, column)` to true. Put another way, insert
@@ -1983,17 +1988,17 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
19831988 self . row ( row) . into_iter ( ) . flat_map ( |r| r. iter ( ) )
19841989 }
19851990
1986- pub fn row ( & self , row : R ) -> Option < & HybridBitSet < C > > {
1991+ pub fn row ( & self , row : R ) -> Option < & ChunkedBitSet < C > > {
19871992 self . rows . get ( row) ?. as_ref ( )
19881993 }
19891994
19901995 /// Intersects `row` with `set`. `set` can be either `BitSet` or
1991- /// `HybridBitSet `. Has no effect if `row` does not exist.
1996+ /// `ChunkedBitSet `. Has no effect if `row` does not exist.
19921997 ///
19931998 /// Returns true if the row was changed.
19941999 pub fn intersect_row < Set > ( & mut self , row : R , set : & Set ) -> bool
19952000 where
1996- HybridBitSet < C > : BitRelations < Set > ,
2001+ ChunkedBitSet < C > : BitRelations < Set > ,
19972002 {
19982003 match self . rows . get_mut ( row) {
19992004 Some ( Some ( row) ) => row. intersect ( set) ,
@@ -2002,12 +2007,12 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
20022007 }
20032008
20042009 /// Subtracts `set` from `row`. `set` can be either `BitSet` or
2005- /// `HybridBitSet `. Has no effect if `row` does not exist.
2010+ /// `ChunkedBitSet `. Has no effect if `row` does not exist.
20062011 ///
20072012 /// Returns true if the row was changed.
20082013 pub fn subtract_row < Set > ( & mut self , row : R , set : & Set ) -> bool
20092014 where
2010- HybridBitSet < C > : BitRelations < Set > ,
2015+ ChunkedBitSet < C > : BitRelations < Set > ,
20112016 {
20122017 match self . rows . get_mut ( row) {
20132018 Some ( Some ( row) ) => row. subtract ( set) ,
@@ -2016,12 +2021,12 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
20162021 }
20172022
20182023 /// Unions `row` with `set`. `set` can be either `BitSet` or
2019- /// `HybridBitSet `.
2024+ /// `ChunkedBitSet `.
20202025 ///
20212026 /// Returns true if the row was changed.
20222027 pub fn union_row < Set > ( & mut self , row : R , set : & Set ) -> bool
20232028 where
2024- HybridBitSet < C > : BitRelations < Set > ,
2029+ ChunkedBitSet < C > : BitRelations < Set > ,
20252030 {
20262031 self . ensure_row ( row) . union ( set)
20272032 }
0 commit comments