Skip to content

Commit

Permalink
reset LinearMap.size when expanding buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
ttaubert committed Dec 30, 2012
1 parent 4be7310 commit 4b1d2dc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/libcore/send_map.rs
Expand Up @@ -173,6 +173,7 @@ pub mod linear {
let mut old_buckets = vec::from_fn(new_capacity, |_i| None);
self.buckets <-> old_buckets;

self.size = 0;
for uint::range(0, old_capacity) |i| {
let mut bucket = None;
bucket <-> old_buckets[i];
Expand Down Expand Up @@ -583,4 +584,22 @@ pub mod test {

assert m1 == m2;
}

#[test]
pub fn test_expand() {
let mut m = ~LinearMap();

assert m.len() == 0;
assert m.is_empty();

let mut i = 0u;
let old_resize_at = m.resize_at;
while old_resize_at == m.resize_at {
m.insert(i, i);
i += 1;
}

assert m.len() == i;
assert !m.is_empty();
}
}

0 comments on commit 4b1d2dc

Please sign in to comment.