Skip to content

Commit 1ba5f5b

Browse files
committed
---
yaml --- r: 42871 b: refs/heads/try c: 9ba7114 h: refs/heads/master i: 42869: 046909e 42867: 6582df1 42863: aa33ecf v: v3
1 parent 5e19b43 commit 1ba5f5b

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
@@ -2,7 +2,7 @@
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5-
refs/heads/try: aac91267e3ea650649ee443b042fe04cd502da6c
5+
refs/heads/try: 9ba7114515db355ca36065d2730e3ee6c84cd6d1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/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)