File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5
- refs/heads/try: aac91267e3ea650649ee443b042fe04cd502da6c
5
+ refs/heads/try: 9ba7114515db355ca36065d2730e3ee6c84cd6d1
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ impl<V> SmallIntMap<V>: Container {
95
95
pure fn is_empty ( & self ) -> bool { self . len ( ) == 0 }
96
96
}
97
97
98
+ impl < V > SmallIntMap < V > : Mutable {
99
+ fn clear ( & mut self ) { self . v . set ( ~[ ] ) }
100
+ }
101
+
98
102
/// Implements the map::map interface for smallintmap
99
103
impl < V : Copy > SmallIntMap < V > {
100
104
#[ inline( always) ]
@@ -111,9 +115,6 @@ impl<V: Copy> SmallIntMap<V> {
111
115
self . v . set_elt ( key, None ) ;
112
116
old. is_some ( )
113
117
}
114
- fn clear ( ) {
115
- self . v . set ( ~[ ] ) ;
116
- }
117
118
pure fn contains_key ( key : uint ) -> bool {
118
119
contains_key ( self , key)
119
120
}
@@ -191,6 +192,19 @@ mod tests {
191
192
assert !map. is_empty ( ) ;
192
193
}
193
194
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
+
194
208
#[ test]
195
209
fn test_insert_with_key ( ) {
196
210
let map: SmallIntMap < uint > = mk ( ) ;
You can’t perform that action at this time.
0 commit comments