@@ -61,21 +61,21 @@ impl<T: Idx> BitSet<T> {
61
61
}
62
62
63
63
/// Sets all elements up to and including `size`.
64
- pub fn set_up_to ( & mut self , bit : usize ) {
64
+ pub fn set_up_to ( & mut self , elem : usize ) {
65
65
for word in & mut self . words {
66
66
* word = !0 ;
67
67
}
68
- self . clear_above ( bit ) ;
68
+ self . clear_above ( elem ) ;
69
69
}
70
70
71
- /// Clear all elements above `bit `.
72
- fn clear_above ( & mut self , bit : usize ) {
73
- let first_clear_block = bit / WORD_BITS ;
71
+ /// Clear all elements above `elem `.
72
+ fn clear_above ( & mut self , elem : usize ) {
73
+ let first_clear_block = elem / WORD_BITS ;
74
74
75
75
if first_clear_block < self . words . len ( ) {
76
- // Within `first_clear_block`, the `bit % WORD_BITS` LSBs should
76
+ // Within `first_clear_block`, the `elem % WORD_BITS` LSBs should
77
77
// remain.
78
- let mask = ( 1 << ( bit % WORD_BITS ) ) - 1 ;
78
+ let mask = ( 1 << ( elem % WORD_BITS ) ) - 1 ;
79
79
self . words [ first_clear_block] &= mask;
80
80
81
81
// All the blocks above `first_clear_block` are fully cleared.
@@ -96,10 +96,10 @@ impl<T: Idx> BitSet<T> {
96
96
self . words . iter ( ) . map ( |e| e. count_ones ( ) as usize ) . sum ( )
97
97
}
98
98
99
- /// True if `self` contains the bit `bit `.
99
+ /// True if `self` contains `elem `.
100
100
#[ inline]
101
- pub fn contains ( & self , bit : T ) -> bool {
102
- let ( word_index, mask) = word_index_and_mask ( bit ) ;
101
+ pub fn contains ( & self , elem : T ) -> bool {
102
+ let ( word_index, mask) = word_index_and_mask ( elem ) ;
103
103
( self . words [ word_index] & mask) != 0
104
104
}
105
105
@@ -118,10 +118,10 @@ impl<T: Idx> BitSet<T> {
118
118
self . words . iter ( ) . all ( |a| * a == 0 )
119
119
}
120
120
121
- /// Insert a bit . Returns true if the bit has changed.
121
+ /// Insert `elem` . Returns true if the set has changed.
122
122
#[ inline]
123
- pub fn insert ( & mut self , bit : T ) -> bool {
124
- let ( word_index, mask) = word_index_and_mask ( bit ) ;
123
+ pub fn insert ( & mut self , elem : T ) -> bool {
124
+ let ( word_index, mask) = word_index_and_mask ( elem ) ;
125
125
let word_ref = & mut self . words [ word_index] ;
126
126
let word = * word_ref;
127
127
let new_word = word | mask;
@@ -136,10 +136,10 @@ impl<T: Idx> BitSet<T> {
136
136
}
137
137
}
138
138
139
- /// Returns true if the bit has changed.
139
+ /// Returns true if the set has changed.
140
140
#[ inline]
141
- pub fn remove ( & mut self , bit : T ) -> bool {
142
- let ( word_index, mask) = word_index_and_mask ( bit ) ;
141
+ pub fn remove ( & mut self , elem : T ) -> bool {
142
+ let ( word_index, mask) = word_index_and_mask ( elem ) ;
143
143
let word_ref = & mut self . words [ word_index] ;
144
144
let word = * word_ref;
145
145
let new_word = word & !mask;
@@ -547,16 +547,16 @@ impl<T: Idx> GrowableBitSet<T> {
547
547
GrowableBitSet { bit_set : BitSet :: new_empty ( bits) }
548
548
}
549
549
550
- /// Returns true if the bit has changed.
550
+ /// Returns true if the set has changed.
551
551
#[ inline]
552
- pub fn insert ( & mut self , bit : T ) -> bool {
553
- self . grow ( bit ) ;
554
- self . bit_set . insert ( bit )
552
+ pub fn insert ( & mut self , elem : T ) -> bool {
553
+ self . grow ( elem ) ;
554
+ self . bit_set . insert ( elem )
555
555
}
556
556
557
557
#[ inline]
558
- pub fn contains ( & self , bit : T ) -> bool {
559
- let ( word_index, mask) = word_index_and_mask ( bit ) ;
558
+ pub fn contains ( & self , elem : T ) -> bool {
559
+ let ( word_index, mask) = word_index_and_mask ( elem ) ;
560
560
if let Some ( word) = self . bit_set . words . get ( word_index) {
561
561
( word & mask) != 0
562
562
} else {
0 commit comments