From 83270d2d792fb519481f6df87f23d73c767ec5f9 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 7 Feb 2013 17:49:57 -0500 Subject: rm each method from the Map trait the map types should implement BaseIter instead --- src/libstd/smallintmap.rs | 20 ++++++++++---------- src/libstd/treemap.rs | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 9af596eb1f5..218964695e2 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -48,16 +48,6 @@ impl SmallIntMap: Map { 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 SmallIntMap { /// Create an empty SmallIntMap static pure fn new() -> SmallIntMap { 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") } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 1e90abcc03d..70226c7277d 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -125,9 +125,6 @@ impl TreeMap: Map { self.find(key).is_some() } - /// Visit all key-value pairs in order - pure fn each(&self, f: fn(&K, &V) -> bool) { each(&self.root, f) } - /// Visit all keys in order pure fn each_key(&self, f: fn(&K) -> bool) { self.each(|k, _| f(k)) } @@ -175,6 +172,9 @@ impl TreeMap { /// Create an empty TreeMap static pure fn new() -> TreeMap { TreeMap{root: None, length: 0} } + /// Visit all key-value pairs in order + pure fn each(&self, f: fn(&K, &V) -> bool) { each(&self.root, f) } + /// Visit all key-value pairs in reverse order pure fn each_reverse(&self, f: fn(&K, &V) -> bool) { each_reverse(&self.root, f); -- cgit 1.4.1-3-g733a5