Let's have Set implement forEach, like Map does.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5500 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Par Winzell
2008-11-04 18:21:29 +00:00
parent 14755a6cea
commit 4bc5627d82
3 changed files with 18 additions and 0 deletions
@@ -62,6 +62,14 @@ public class ExpiringSet extends EventDispatcher
_data.length = 0;
}
// from Set
public function forEach (fn :Function) :void
{
for each (var e :ExpiringElement in _data) {
fn(e);
}
}
// from Set
public function size () :int
{
+7
View File
@@ -76,6 +76,13 @@ public class HashSet
return (_hashMap.containsKey(o));
}
public function forEach (fn :Function) :void
{
_hashMap.forEach(function (key :Object, val :Object) :void {
fn(key);
});
}
public function size () :int
{
return (_hashMap.size());
+3
View File
@@ -41,6 +41,9 @@ public interface Set
/** Returns true if this set contains the specified element. */
function contains (o :Object) :Boolean;
/** Call the specified function, which accepts an element as an argument. */
function forEach (fn :Function) :void;
/** Retuns the number of elements in this set. */
function size () :int; // @TSC - should this be uint?