Packageorg.spicefactory.lib.collection
Classpublic class Set
InheritanceSet Inheritance Object

Simple Set implementation, an unordered collection that does not allow duplicates. Within the Spicefactory libraries and frameworks these collections are usually only used inside the implementations, but not exposed in the public APIs.

Due to limitations in the Flash Proxy class which only accepts String-based keys, the Set class does not support for and for each loops or bracket access for reading and writing values. For loops you can loop over Set.toArray() instead.



Public Methods
 MethodDefined By
  
Set(items:Array = null)
Creates a new instance.
Set
  
add(item:Object):Boolean
Adds the specified item to this set if it was not already present.
Set
  
Clones this set.
Set
  
contains(item:Object):Boolean
Indicates whether this set contains the specified item.
Set
  
isEmpty():Boolean
Indicates whether this set is empty.
Set
  
remove(item:Object):Boolean
Removes the specified item from this set.
Set
  
removeAll():void
Removes all items from this set.
Set
  
size():uint
Returns the number of items in this set.
Set
  
toArray():Array
Returns the items of this set in no particular order as an Array.
Set
Constructor Detail
Set()Constructor
public function Set(items:Array = null)

Creates a new instance.

Parameters
items:Array (default = null) — the items to populate the set with
Method Detail
add()method
public function add(item:Object):Boolean

Adds the specified item to this set if it was not already present.

Parameters

item:Object — the item to add to this set

Returns
Boolean — true if the item was added to this set or false if it was already present
clone()method 
public function clone():Set

Clones this set. Modifications in the clone are not reflected in the original set and vice versa.

Returns
Set — a clone of this set
contains()method 
public function contains(item:Object):Boolean

Indicates whether this set contains the specified item.

Parameters

item:Object — the item to check

Returns
Boolean — true if this set contains the specified item
isEmpty()method 
public function isEmpty():Boolean

Indicates whether this set is empty.

Returns
Boolean — true if this set does not contain any items.
remove()method 
public function remove(item:Object):Boolean

Removes the specified item from this set.

Parameters

item:Object — the item to remove from this set

Returns
Boolean — true if the item was removed from this set or false if this set does not contain this item
removeAll()method 
public function removeAll():void

Removes all items from this set.

size()method 
public function size():uint

Returns the number of items in this set.

Returns
uint — the number of items in this set
toArray()method 
public function toArray():Array

Returns the items of this set in no particular order as an Array.

Returns
Array — the items of this set as an Array