Packagecom.threerings.util.sets
Classpublic class SetBuilder

Builds Sets.


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



Public Methods
 MethodDefined by
  
SetBuilder(valueClazz:Class)
SetBuilder
  
add(value:Object):SetBuilder
Add a value to the Set, once built.
SetBuilder
  
addAll(values:Array):SetBuilder
Adds all objects in the values Array to the Set, once built.
SetBuilder
  
Build the Set!
SetBuilder
  
makeExpiring(ttl:int, expireHandler:Function = null):SetBuilder
Make the Set auto-expire elements.
SetBuilder
  
Make the Set immutable.
SetBuilder
  
makeLR(maxSize:int, accessOrder:Boolean = true):SetBuilder
Make the Set a cache, disposing of the least-recently-accessed (or just inserted) value whenever size exceeds maxSize.
SetBuilder
  
makeSorted(comp:Function = null):SetBuilder
Make the Map sorted.
SetBuilder
Constructor detail
SetBuilder()constructor
public function SetBuilder(valueClazz:Class)Parameters
valueClazz:Class
Method detail
add()method
public function add(value:Object):SetBuilder

Add a value to the Set, once built.

Parameters
value:Object

Returns
SetBuilder
addAll()method 
public function addAll(values:Array):SetBuilder

Adds all objects in the values Array to the Set, once built.

Parameters
values:Array

Returns
SetBuilder
build()method 
public function build():Set

Build the Set!

Returns
Set
makeExpiring()method 
public function makeExpiring(ttl:int, expireHandler:Function = null):SetBuilder

Make the Set auto-expire elements.

Parameters
ttl:int — the time to live
 
expireHandler:Function (default = null) — function to receieve notifications when an element expires. signature: function (element :Object) :void;

Returns
SetBuilder — this SetBuilder, for chaining.
makeImmutable()method 
public function makeImmutable():SetBuilder

Make the Set immutable.

Returns
SetBuilder
makeLR()method 
public function makeLR(maxSize:int, accessOrder:Boolean = true):SetBuilder

Make the Set a cache, disposing of the least-recently-accessed (or just inserted) value whenever size exceeds maxSize. Iterating over this Set (via forEach() or toArray()) will see the oldest entries first.

Parameters
maxSize:int
 
accessOrder:Boolean (default = true)

Returns
SetBuilder — this SetBuilder, for chaining.
makeSorted()method 
public function makeSorted(comp:Function = null):SetBuilder

Make the Map sorted. If no Comparator is specified, then one is picked based on the valueClazz, falling back to Comparators.compareUnknowns.

Parameters
comp:Function (default = null)

Returns
SetBuilder — this SetBuilder, for chaining.