Packagecom.threerings.util
Classpublic class Sets

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 Methods
 MethodDefined by
  
addAll(theSet:Set, objects:Array):Boolean
[static] Adds an Array of objects to the given set.
Sets
  
difference(a:Set, b:Set, result:Set):Set
[static] Calculates a - b and places it in result.
Sets
  
equals(a:Set, b:Set):Boolean
[static] Return true if the two sets are equal.
Sets
  
intersection(a:Set, b:Set, result:Set):Set
[static] Calculates the intersection of a and b and places it in result.
Sets
  
newBuilder(valueClazz:Class):SetBuilder
[static] Create a SetBuilder for creating a more complicated Set type.
Sets
  
newSetOf(valueClazz:Class):Set
[static] Create a new Set for storing values of the specified class.
Sets
  
newSortedSetOf(valueClazz:Class, comp:Function = null):Set
[static] Create a new sorted Set for storing value of the specified class.
Sets
  
some(theSet:Set, condition:Function):Boolean
[static] Tests if at least one entry in a set meets a condition.
Sets
  
union(a:Set, b:Set, result:Set):Set
[static] Calculates the union of a and b and places it in result.
Sets
Protected Methods
 MethodDefined by
  
checkSets(a:Set, b:Set, result:Set):void
[static] Helper method for Set operations.
Sets
Method detail
addAll()method
public static function addAll(theSet:Set, objects:Array):Boolean

Adds an Array of objects to the given set.

Parameters
theSet:Set
 
objects:Array

Returns
Boolean — true if any object was added to the set, and false otherwise.
checkSets()method 
protected static function checkSets(a:Set, b:Set, result:Set):void

Helper method for Set operations.

Parameters
a:Set
 
b:Set
 
result:Set
difference()method 
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
a:Set
 
b:Set
 
result:Set

Returns
Set — result
equals()method 
public static function equals(a:Set, b:Set):Boolean

Return true if the two sets are equal.

Parameters
a:Set
 
b:Set

Returns
Boolean
intersection()method 
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
a:Set
 
b:Set
 
result:Set

Returns
Set — result
newBuilder()method 
public static function newBuilder(valueClazz:Class):SetBuilder

Create a SetBuilder for creating a more complicated Set type.

Parameters
valueClazz:Class

Returns
SetBuilder

Example
     // builds a sorted Set that keeps the 10 most-recently inserted entries.
     var mySet :Set = Sets.newBuilder(String)
         .makeSorted()
         .makeLRI(10)
         .build();
     

newSetOf()method 
public static function newSetOf(valueClazz:Class):Set

Create a new Set for storing values of the specified class.

Parameters
valueClazz:Class

Returns
Set
newSortedSetOf()method 
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
Set
some()method 
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
Boolean

See also

union()method 
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
a:Set
 
b:Set
 
result:Set

Returns
Set — result