@@ -18,7 +18,6 @@ use core::iter::{Enumerate, Repeat, Map, Zip};
18
18
use core:: ops;
19
19
use core:: slice;
20
20
use core:: uint;
21
- use std:: hash;
22
21
23
22
use vec:: Vec ;
24
23
@@ -35,12 +34,12 @@ fn small_mask(nbits: uint) -> uint {
35
34
}
36
35
37
36
impl SmallBitv {
38
- fn new ( bits : uint ) -> SmallBitv {
37
+ pub fn new ( bits : uint ) -> SmallBitv {
39
38
SmallBitv { bits : bits}
40
39
}
41
40
42
41
#[ inline]
43
- fn bits_op ( & mut self ,
42
+ pub fn bits_op ( & mut self ,
44
43
right_bits : uint ,
45
44
nbits : uint ,
46
45
f : |uint , uint| -> uint)
@@ -53,32 +52,32 @@ impl SmallBitv {
53
52
}
54
53
55
54
#[ inline]
56
- fn union ( & mut self , s : & SmallBitv , nbits : uint ) -> bool {
55
+ pub fn union ( & mut self , s : & SmallBitv , nbits : uint ) -> bool {
57
56
self . bits_op ( s. bits , nbits, |u1, u2| u1 | u2)
58
57
}
59
58
60
59
#[ inline]
61
- fn intersect ( & mut self , s : & SmallBitv , nbits : uint ) -> bool {
60
+ pub fn intersect ( & mut self , s : & SmallBitv , nbits : uint ) -> bool {
62
61
self . bits_op ( s. bits , nbits, |u1, u2| u1 & u2)
63
62
}
64
63
65
64
#[ inline]
66
- fn become ( & mut self , s : & SmallBitv , nbits : uint ) -> bool {
65
+ pub fn become ( & mut self , s : & SmallBitv , nbits : uint ) -> bool {
67
66
self . bits_op ( s. bits , nbits, |_u1, u2| u2)
68
67
}
69
68
70
69
#[ inline]
71
- fn difference ( & mut self , s : & SmallBitv , nbits : uint ) -> bool {
70
+ pub fn difference ( & mut self , s : & SmallBitv , nbits : uint ) -> bool {
72
71
self . bits_op ( s. bits , nbits, |u1, u2| u1 & !u2)
73
72
}
74
73
75
74
#[ inline]
76
- fn get ( & self , i : uint ) -> bool {
75
+ pub fn get ( & self , i : uint ) -> bool {
77
76
( self . bits & ( 1 << i) ) != 0
78
77
}
79
78
80
79
#[ inline]
81
- fn set ( & mut self , i : uint , x : bool ) {
80
+ pub fn set ( & mut self , i : uint , x : bool ) {
82
81
if x {
83
82
self . bits |= 1 <<i;
84
83
}
@@ -88,29 +87,29 @@ impl SmallBitv {
88
87
}
89
88
90
89
#[ inline]
91
- fn equals ( & self , b : & SmallBitv , nbits : uint ) -> bool {
90
+ pub fn equals ( & self , b : & SmallBitv , nbits : uint ) -> bool {
92
91
let mask = small_mask ( nbits) ;
93
92
mask & self . bits == mask & b. bits
94
93
}
95
94
96
95
#[ inline]
97
- fn clear ( & mut self ) { self . bits = 0 ; }
96
+ pub fn clear ( & mut self ) { self . bits = 0 ; }
98
97
99
98
#[ inline]
100
- fn set_all ( & mut self ) { self . bits = !0 ; }
99
+ pub fn set_all ( & mut self ) { self . bits = !0 ; }
101
100
102
101
#[ inline]
103
- fn all ( & self , nbits : uint ) -> bool {
102
+ pub fn all ( & self , nbits : uint ) -> bool {
104
103
small_mask ( nbits) & !self . bits == 0
105
104
}
106
105
107
106
#[ inline]
108
- fn none ( & self , nbits : uint ) -> bool {
107
+ pub fn none ( & self , nbits : uint ) -> bool {
109
108
small_mask ( nbits) & self . bits == 0
110
109
}
111
110
112
111
#[ inline]
113
- fn negate ( & mut self ) { self . bits = !self . bits ; }
112
+ pub fn negate ( & mut self ) { self . bits = !self . bits ; }
114
113
}
115
114
116
115
#[ deriving( Clone ) ]
@@ -135,12 +134,12 @@ fn big_mask(nbits: uint, elem: uint) -> uint {
135
134
}
136
135
137
136
impl BigBitv {
138
- fn new ( storage : Vec < uint > ) -> BigBitv {
137
+ pub fn new ( storage : Vec < uint > ) -> BigBitv {
139
138
BigBitv { storage : storage}
140
139
}
141
140
142
141
#[ inline]
143
- fn process ( & mut self ,
142
+ pub fn process ( & mut self ,
144
143
b : & BigBitv ,
145
144
nbits : uint ,
146
145
op : |uint , uint| -> uint)
@@ -164,45 +163,45 @@ impl BigBitv {
164
163
}
165
164
166
165
#[ inline]
167
- fn each_storage ( & mut self , op: |v: & mut uint | -> bool ) -> bool {
166
+ pub fn each_storage ( & mut self , op: |v: & mut uint | -> bool ) -> bool {
168
167
self . storage . mut_iter ( ) . advance ( |elt| op ( elt) )
169
168
}
170
169
171
170
#[ inline]
172
- fn negate ( & mut self ) {
171
+ pub fn negate ( & mut self ) {
173
172
self . each_storage ( |w| { * w = !* w; true } ) ;
174
173
}
175
174
176
175
#[ inline]
177
- fn union ( & mut self , b : & BigBitv , nbits : uint ) -> bool {
176
+ pub fn union ( & mut self , b : & BigBitv , nbits : uint ) -> bool {
178
177
self . process ( b, nbits, |w1, w2| w1 | w2)
179
178
}
180
179
181
180
#[ inline]
182
- fn intersect ( & mut self , b : & BigBitv , nbits : uint ) -> bool {
181
+ pub fn intersect ( & mut self , b : & BigBitv , nbits : uint ) -> bool {
183
182
self . process ( b, nbits, |w1, w2| w1 & w2)
184
183
}
185
184
186
185
#[ inline]
187
- fn become ( & mut self , b : & BigBitv , nbits : uint ) -> bool {
186
+ pub fn become ( & mut self , b : & BigBitv , nbits : uint ) -> bool {
188
187
self . process ( b, nbits, |_, w| w)
189
188
}
190
189
191
190
#[ inline]
192
- fn difference ( & mut self , b : & BigBitv , nbits : uint ) -> bool {
191
+ pub fn difference ( & mut self , b : & BigBitv , nbits : uint ) -> bool {
193
192
self . process ( b, nbits, |w1, w2| w1 & !w2)
194
193
}
195
194
196
195
#[ inline]
197
- fn get ( & self , i : uint ) -> bool {
196
+ pub fn get ( & self , i : uint ) -> bool {
198
197
let w = i / uint:: BITS ;
199
198
let b = i % uint:: BITS ;
200
199
let x = 1 & self . storage . get ( w) >> b;
201
200
x == 1
202
201
}
203
202
204
203
#[ inline]
205
- fn set ( & mut self , i : uint , x : bool ) {
204
+ pub fn set ( & mut self , i : uint , x : bool ) {
206
205
let w = i / uint:: BITS ;
207
206
let b = i % uint:: BITS ;
208
207
let flag = 1 << b;
@@ -211,7 +210,7 @@ impl BigBitv {
211
210
}
212
211
213
212
#[ inline]
214
- fn equals ( & self , b : & BigBitv , nbits : uint ) -> bool {
213
+ pub fn equals ( & self , b : & BigBitv , nbits : uint ) -> bool {
215
214
for ( i, elt) in b. storage . iter ( ) . enumerate ( ) {
216
215
let mask = big_mask ( nbits, i) ;
217
216
if mask & * self . storage . get ( i) != mask & * elt {
@@ -597,20 +596,6 @@ impl fmt::Show for Bitv {
597
596
}
598
597
}
599
598
600
- impl < S : hash:: Writer > hash:: Hash < S > for Bitv {
601
- fn hash ( & self , state : & mut S ) {
602
- self . nbits . hash ( state) ;
603
- match self . rep {
604
- Small ( ref s) => ( s. bits & small_mask ( self . nbits ) ) . hash ( state) ,
605
- Big ( ref b) => {
606
- for ( i, ele) in b. storage . iter ( ) . enumerate ( ) {
607
- ( ele & big_mask ( self . nbits , i) ) . hash ( state) ;
608
- }
609
- }
610
- }
611
- }
612
- }
613
-
614
599
#[ inline]
615
600
fn iterate_bits ( base : uint , bits : uint , f: |uint| -> bool) -> bool {
616
601
if bits == 0 {
@@ -849,14 +834,6 @@ impl fmt::Show for BitvSet {
849
834
}
850
835
}
851
836
852
- impl < S : hash:: Writer > hash:: Hash < S > for BitvSet {
853
- fn hash ( & self , state : & mut S ) {
854
- for pos in self . iter ( ) {
855
- pos. hash ( state) ;
856
- }
857
- }
858
- }
859
-
860
837
impl Container for BitvSet {
861
838
#[ inline]
862
839
fn len ( & self ) -> uint { self . size }
0 commit comments