Skip to content

Commit e211e59

Browse files
committed
---
yaml --- r: 41404 b: refs/heads/snap-stage3 c: 9ba7114 h: refs/heads/master v: v3
1 parent 3ece08b commit e211e59

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,7 +1,7 @@
11
---
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: aac91267e3ea650649ee443b042fe04cd502da6c
4+
refs/heads/snap-stage3: 9ba7114515db355ca36065d2730e3ee6c84cd6d1
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)