Skip to content

Commit b633872

Browse files
committed
---
yaml --- r: 42205 b: refs/heads/master c: 9ba7114 h: refs/heads/master i: 42203: 5240d01 v: v3
1 parent 2eb9861 commit b633872

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: aac91267e3ea650649ee443b042fe04cd502da6c
2+
refs/heads/master: 9ba7114515db355ca36065d2730e3ee6c84cd6d1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/libstd/smallintmap.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ impl<V> SmallIntMap<V>: Container {
9595
pure fn is_empty(&self) -> bool { self.len() == 0 }
9696
}
9797

98+
impl<V> SmallIntMap<V>: Mutable {
99+
fn clear(&mut self) { self.v.set(~[]) }
100+
}
101+
98102
/// Implements the map::map interface for smallintmap
99103
impl<V: Copy> SmallIntMap<V> {
100104
#[inline(always)]
@@ -111,9 +115,6 @@ impl<V: Copy> SmallIntMap<V> {
111115
self.v.set_elt(key, None);
112116
old.is_some()
113117
}
114-
fn clear() {
115-
self.v.set(~[]);
116-
}
117118
pure fn contains_key(key: uint) -> bool {
118119
contains_key(self, key)
119120
}
@@ -191,6 +192,19 @@ mod tests {
191192
assert !map.is_empty();
192193
}
193194

195+
#[test]
196+
fn test_clear() {
197+
let mut map = mk();
198+
map.insert(5, 20);
199+
map.insert(11, 12);
200+
map.insert(14, 22);
201+
map.clear();
202+
assert map.is_empty();
203+
assert map.find(5).is_none();
204+
assert map.find(11).is_none();
205+
assert map.find(14).is_none();
206+
}
207+
194208
#[test]
195209
fn test_insert_with_key() {
196210
let map: SmallIntMap<uint> = mk();

0 commit comments

Comments
 (0)