Factory methods for creating Sets.
Example
// contains the userIds of seen players
var seenUsers :Set = Sets.newSetOf(int);
// contains a cache of the last 5 added instances of the Hashable class User.
var users :Set = Sets.newBuilder(User).makeLRI(5).build();
public static function addAll(theSet:Set, objects:Array):Boolean
Adds an Array of objects to the given set.
Parameters
Returns
| Boolean — true if any object was added to the set, and false otherwise.
|
protected static function checkSets(a:Set, b:Set, result:Set):void
Helper method for Set operations.
Parameters
public static function difference(a:Set, b:Set, result:Set):Set
Calculates a - b and places it in result.
a and b are unmodified. result must be empty, and must not be a or b.
Parameters
Returns
public static function equals(a:Set, b:Set):Boolean
Return true if the two sets are equal.
Parameters
Returns
public static function intersection(a:Set, b:Set, result:Set):Set
Calculates the intersection of a and b and places it in result.
a and b are unmodified. result must be empty, and must not be a or b.
Parameters
Returns
public static function newBuilder(valueClazz:Class):SetBuilder
Create a SetBuilder for creating a more complicated Set type.
Parameters
Returns
Example
// builds a sorted Set that keeps the 10 most-recently inserted entries.
var mySet :Set = Sets.newBuilder(String)
.makeSorted()
.makeLRI(10)
.build();
public static function newSetOf(valueClazz:Class):Set
Create a new Set for storing values of the specified class.
Parameters
Returns
public static function newSortedSetOf(valueClazz:Class, comp:Function = null):Set
Create a new sorted Set for storing value of the specified class.
Parameters
| valueClazz:Class |
|
| comp:Function (default = null )
|
Returns
public static function some(theSet:Set, condition:Function):Boolean
Tests if at least one entry in a set meets a condition.
Parameters
| theSet:Set — the set whose entries are to be tested
|
|
| condition:Function — a function that tests a set entry:
function condition (o :Object) :Boolean
|
Returns
See also
public static function union(a:Set, b:Set, result:Set):Set
Calculates the union of a and b and places it in result.
a and b are unmodified. result must be empty, and must not be a or b.
Parameters
Returns
Copyright © 2007-2009 Three Rings Design, Inc.