rm each method from the Map trait

the map types should implement BaseIter instead
This commit is contained in:
Daniel Micay
2013-02-07 17:49:57 -05:00
parent d903231f1e
commit 83270d2d79
5 changed files with 41 additions and 39 deletions

View File

@@ -48,16 +48,6 @@ impl<V> SmallIntMap<V>: Map<uint, V> {
self.find(key).is_some()
}
/// Visit all key-value pairs
pure fn each(&self, it: fn(key: &uint, value: &V) -> bool) {
for uint::range(0, self.v.len()) |i| {
match self.v[i] {
Some(ref elt) => if !it(&i, elt) { break },
None => ()
}
}
}
/// Visit all keys
pure fn each_key(&self, blk: fn(key: &uint) -> bool) {
self.each(|k, _| blk(k))
@@ -109,6 +99,16 @@ pub impl<V> SmallIntMap<V> {
/// Create an empty SmallIntMap
static pure fn new() -> SmallIntMap<V> { SmallIntMap{v: ~[]} }
/// Visit all key-value pairs
pure fn each(&self, it: fn(key: &uint, value: &V) -> bool) {
for uint::range(0, self.v.len()) |i| {
match self.v[i] {
Some(ref elt) => if !it(&i, elt) { break },
None => ()
}
}
}
pure fn get(&self, key: &uint) -> &self/V {
self.find(key).expect("key not present")
}