File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ mod linear {
229
229
self . insert_bucket ( bucket) ;
230
230
idx = self . next_bucket ( idx, len_buckets) ;
231
231
}
232
+ self . size -= 1 ;
232
233
ret true;
233
234
}
234
235
}
@@ -240,10 +241,14 @@ mod linear {
240
241
}
241
242
242
243
impl public_methods < K , V > for & const linear_map < K , V > {
243
- fn size ( ) -> uint {
244
+ fn len ( ) -> uint {
244
245
self . size
245
246
}
246
247
248
+ fn is_empty ( ) -> bool {
249
+ self . len ( ) == 0
250
+ }
251
+
247
252
fn contains_key ( k : & K ) -> bool {
248
253
alt self . bucket_for_key ( self . buckets , k) {
249
254
found_entry ( _) => { true }
@@ -377,6 +382,15 @@ mod test {
377
382
assert m. get ( & 5 ) == 3 ;
378
383
}
379
384
385
+ #[ test]
386
+ fn empty ( ) {
387
+ let mut m = ~linear:: linear_map_with_capacity ( uint_hash, uint_eq, 4 ) ;
388
+ assert m. insert ( 1 , 2 ) ;
389
+ assert !m. is_empty ( ) ;
390
+ assert m. remove ( & 1 ) ;
391
+ assert m. is_empty ( ) ;
392
+ }
393
+
380
394
#[ test]
381
395
fn iterate ( ) {
382
396
let mut m = linear:: linear_map_with_capacity ( uint_hash, uint_eq, 4 ) ;
You can’t perform that action at this time.
0 commit comments