Packageas3.collections
Classpublic class Set
ImplementsISet

Basic ISet implementation.

The set is basically a wrapper to an internal map instance, where the set's items serve as the map keys.

An exception will be thrown for any trial to add an item that does not match with the type of the internal TypedDictionary instance. In other words, adding items of a consistent type will not cause any exception. See the head section of the TypedDictionary for more information.

Runtime of operations (ignores Flash Dictionary runtime)

See also

as3.collections.core.TypedDictionary


Public Properties
 PropertyDefined by
  numItems : uint
[read-only] Returns the size of the collection.
Set
Protected Properties
 PropertyDefined by
  _map : IMap
The internal map.
Set
Public Methods
 MethodDefined by
  
Set()
Creates a new Set.
Set
  
addItem(item:*):Boolean
Adds an item to the set.
Set
  
clear():void
Removes all items from the collection.
Set
  
getIterator(cursor:uint = 0):IIterator
Returns an iterator over the set items starting at the specified position.
Set
  
hasItem(item:*):Boolean
Tests, if an item is contained by the set.
Set
  
removeItem(item:*):Boolean
Removes an item from the set.
Set
  
toArray():Array
Returns an array of all items in the order of the particular collection.
Set
  
toString():String
Info
Set
Property detail
_mapproperty
protected var _map:IMap

The internal map.

numItemsproperty 
numItems:uint  [read-only]

Returns the size of the collection.

Implementation
    public function get numItems():uint
Constructor detail
Set()constructor
public function Set()

Creates a new Set.

Method detail
addItem()method
public function addItem(item:*):Boolean

Adds an item to the set.

Trying to add an item twice leaves the set untouched and returns false.

Parameters
item:* — The item.

Returns
Boolean — true, if the item has been added, else false.

Throws
UnsupportedTypeException — If the item type does not match with the type of the internal map.

See also

clear()method 
public function clear():void

Removes all items from the collection.

getIterator()method 
public function getIterator(cursor:uint = 0):IIterator

Returns an iterator over the set items starting at the specified position.

The iterator of the internal map is returned here. Costs and ordering can be found in the Map documentation.

Parameters
cursor:uint (default = 0) — The position.

Returns
IIterator — The iterator.

See also

hasItem()method 
public function hasItem(item:*):Boolean

Tests, if an item is contained by the set.

Parameters
item:* — The item to test.

Returns
Boolean — true, if the item is contained, else false.
removeItem()method 
public function removeItem(item:*):Boolean

Removes an item from the set.

Trying to remove an item, which is not contained by the set, leaves the set untouched and returns false.

Parameters
item:* — The item to remove.

Returns
Boolean — true, if the item has been removed.
toArray()method 
public function toArray():Array

Returns an array of all items in the order of the particular collection.

Returns
Array — The array.
toString()method 
public function toString():String

Info

Returns
String