@@ -17,23 +17,27 @@ pub struct BitVector {
1717}
1818
1919impl BitVector {
20+ #[ inline]
2021 pub fn new ( num_bits : usize ) -> BitVector {
2122 let num_words = u64s ( num_bits) ;
2223 BitVector { data : vec ! [ 0 ; num_words] }
2324 }
2425
26+ #[ inline]
2527 pub fn clear ( & mut self ) {
2628 for p in & mut self . data {
2729 * p = 0 ;
2830 }
2931 }
3032
33+ #[ inline]
3134 pub fn contains ( & self , bit : usize ) -> bool {
3235 let ( word, mask) = word_mask ( bit) ;
3336 ( self . data [ word] & mask) != 0
3437 }
3538
3639 /// Returns true if the bit has changed.
40+ #[ inline]
3741 pub fn insert ( & mut self , bit : usize ) -> bool {
3842 let ( word, mask) = word_mask ( bit) ;
3943 let data = & mut self . data [ word] ;
@@ -43,6 +47,7 @@ impl BitVector {
4347 new_value != value
4448 }
4549
50+ #[ inline]
4651 pub fn insert_all ( & mut self , all : & BitVector ) -> bool {
4752 assert ! ( self . data. len( ) == all. data. len( ) ) ;
4853 let mut changed = false ;
@@ -56,6 +61,7 @@ impl BitVector {
5661 changed
5762 }
5863
64+ #[ inline]
5965 pub fn grow ( & mut self , num_bits : usize ) {
6066 let num_words = u64s ( num_bits) ;
6167 if self . data . len ( ) < num_words {
@@ -64,6 +70,7 @@ impl BitVector {
6470 }
6571
6672 /// Iterates over indexes of set bits in a sorted order
73+ #[ inline]
6774 pub fn iter < ' a > ( & ' a self ) -> BitVectorIter < ' a > {
6875 BitVectorIter {
6976 iter : self . data . iter ( ) ,
@@ -226,10 +233,12 @@ impl BitMatrix {
226233 }
227234}
228235
236+ #[ inline]
229237fn u64s ( elements : usize ) -> usize {
230238 ( elements + 63 ) / 64
231239}
232240
241+ #[ inline]
233242fn word_mask ( index : usize ) -> ( usize , u64 ) {
234243 let word = index / 64 ;
235244 let mask = 1 << ( index % 64 ) ;
0 commit comments