@@ -453,6 +453,11 @@ impl<T: Idx> ChunkedBitSet<T> {
453
453
ChunkedBitSet :: new ( domain_size, /* is_empty */ false )
454
454
}
455
455
456
+ pub fn clear ( & mut self ) {
457
+ let domain_size = self . domain_size ( ) ;
458
+ * self = ChunkedBitSet :: new_empty ( domain_size) ;
459
+ }
460
+
456
461
#[ cfg( test) ]
457
462
fn chunks ( & self ) -> & [ Chunk ] {
458
463
& self . chunks
@@ -1883,7 +1888,7 @@ impl<R: Idx, C: Idx> fmt::Debug for BitMatrix<R, C> {
1883
1888
/// sparse representation.
1884
1889
///
1885
1890
/// 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 >)`.
1887
1892
/// Furthermore, any previously uninstantiated rows prior to it will be
1888
1893
/// instantiated as `None`. Those prior rows may themselves become fully
1889
1894
/// instantiated later on if any of their bits are set.
@@ -1897,7 +1902,7 @@ where
1897
1902
C : Idx ,
1898
1903
{
1899
1904
num_columns : usize ,
1900
- rows : IndexVec < R , Option < HybridBitSet < C > > > ,
1905
+ rows : IndexVec < R , Option < ChunkedBitSet < C > > > ,
1901
1906
}
1902
1907
1903
1908
impl < R : Idx , C : Idx > SparseBitMatrix < R , C > {
@@ -1906,10 +1911,10 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
1906
1911
Self { num_columns, rows : IndexVec :: new ( ) }
1907
1912
}
1908
1913
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 ) )
1913
1918
}
1914
1919
1915
1920
/// Sets the cell at `(row, column)` to true. Put another way, insert
@@ -1983,17 +1988,17 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
1983
1988
self . row ( row) . into_iter ( ) . flat_map ( |r| r. iter ( ) )
1984
1989
}
1985
1990
1986
- pub fn row ( & self , row : R ) -> Option < & HybridBitSet < C > > {
1991
+ pub fn row ( & self , row : R ) -> Option < & ChunkedBitSet < C > > {
1987
1992
self . rows . get ( row) ?. as_ref ( )
1988
1993
}
1989
1994
1990
1995
/// 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.
1992
1997
///
1993
1998
/// Returns true if the row was changed.
1994
1999
pub fn intersect_row < Set > ( & mut self , row : R , set : & Set ) -> bool
1995
2000
where
1996
- HybridBitSet < C > : BitRelations < Set > ,
2001
+ ChunkedBitSet < C > : BitRelations < Set > ,
1997
2002
{
1998
2003
match self . rows . get_mut ( row) {
1999
2004
Some ( Some ( row) ) => row. intersect ( set) ,
@@ -2002,12 +2007,12 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
2002
2007
}
2003
2008
2004
2009
/// 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.
2006
2011
///
2007
2012
/// Returns true if the row was changed.
2008
2013
pub fn subtract_row < Set > ( & mut self , row : R , set : & Set ) -> bool
2009
2014
where
2010
- HybridBitSet < C > : BitRelations < Set > ,
2015
+ ChunkedBitSet < C > : BitRelations < Set > ,
2011
2016
{
2012
2017
match self . rows . get_mut ( row) {
2013
2018
Some ( Some ( row) ) => row. subtract ( set) ,
@@ -2016,12 +2021,12 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
2016
2021
}
2017
2022
2018
2023
/// Unions `row` with `set`. `set` can be either `BitSet` or
2019
- /// `HybridBitSet `.
2024
+ /// `ChunkedBitSet `.
2020
2025
///
2021
2026
/// Returns true if the row was changed.
2022
2027
pub fn union_row < Set > ( & mut self , row : R , set : & Set ) -> bool
2023
2028
where
2024
- HybridBitSet < C > : BitRelations < Set > ,
2029
+ ChunkedBitSet < C > : BitRelations < Set > ,
2025
2030
{
2026
2031
self . ensure_row ( row) . union ( set)
2027
2032
}
0 commit comments