Packageas3.collections
Classpublic class LinkedSet
InheritanceLinkedSet Inheritance AbstractLinkedList
ImplementsILinkedSet
SubclassesLinkedSetFx

Set made up of sequentially linked objects.

The LinkedSet is a specialisation of the AbstractLinkedList, from that it inherits all functionality, that makes up the linked structure. Additionally, the LinkedSet holds an internal map instance in order to a fast item look-up. The set's items serve as keys in the internal map.

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.

The class defines methods in a custom namespace (as3_collections), which enables safe framework internal access to non public methods.

Runtime of operations (ignores Flash Dictionary runtime)

See also

as3.collections.core.AbstractLinkedList
as3.collections.core.TypedDictionary


Public Properties
 PropertyDefined by
 InheritednumItems : uint
Returns the size of the linked list.
AbstractLinkedList
Protected Properties
 PropertyDefined by
 Inherited_first : LinkedNode
The first item of the linked list.
AbstractLinkedList
 Inherited_last : LinkedNode
The last item of the linked list.
AbstractLinkedList
  _map : IMap
The internal map.
LinkedSet
 Inherited_numItems : uint = 0
The size of the sequence.
AbstractLinkedList
 Inherited_pointer : AbstractPointer
The singleton linked list pointer.
AbstractLinkedList
Public Methods
 MethodDefined by
  
Creates a new LinkedSet.
LinkedSet
  
addItem(item:*):Boolean
Adds an item to the set.
LinkedSet
  
addItemAtEnd(item:*):Boolean
Adds an item at the end of the linked set.
LinkedSet
  
addItemAtStart(item:*):Boolean
Adds an item in front of the linked set.
LinkedSet
  
clear():void
Clears the list by removing the references to the first and last item.
LinkedSet
 Inherited
Returns the first item of the linked list.
AbstractLinkedList
 Inherited
getIterator(cursor:uint = 0):IIterator
Returns an iterator starting at the specified position.
AbstractLinkedList
 Inherited
Returns the last item of the linked list.
AbstractLinkedList
  
Returns a pointer for the linked set.
LinkedSet
  
hasItem(item:*):Boolean
Tests, if an item is contained by the set.
LinkedSet
  
Removes the first item of the linked set.
LinkedSet
  
removeItem(item:*):Boolean
Removes an item from the set.
LinkedSet
  
Removes the last item of the linked set.
LinkedSet
 Inherited
reverse():void
Reverses the linked list order.
AbstractLinkedList
 Inherited
sort(comparator:IComparator):void
Sorts the linked list by a given criterion.
AbstractLinkedList
 Inherited
toArray():Array
Returns an array of all items in the present order.
AbstractLinkedList
  
toString():String
Info
LinkedSet
Protected Methods
 MethodDefined by
 Inherited
Adds the first node to an empty list.
AbstractLinkedList
 Inherited
Inserts a new node after an existing one.
AbstractLinkedList
 Inherited
Inserts a new node at the end of the sequence.
AbstractLinkedList
 Inherited
Inserts a new node at the start of the sequence.
AbstractLinkedList
 Inherited
Inserts a new node before an existing one.
AbstractLinkedList
  
Deregisters a node from the internal map.
LinkedSet
 Inherited
getNodeAt(index:uint):LinkedNode
Returns the node at a specific position.
AbstractLinkedList
 Inherited
insertionSort(comparator:IComparator):void
Insertion sort algorithm.
AbstractLinkedList
 Inherited
mergeSort(comparator:IComparator):void
Merge sort algorithm.
AbstractLinkedList
  
nodeAdded(node:LinkedNode):void
Template method to notify subclasses after a new node has been added.
LinkedSet
  
nodeRemoved():void
Commits the removal of the node, announced in willRemoveNode()
LinkedSet
  
Registers a node in the internal map.
LinkedSet
 Inherited
Unlinks the first node of the sequence.
AbstractLinkedList
 Inherited
Unlinks the last node of the sequence.
AbstractLinkedList
 Inherited
Unlinks a node and connects predecessor with successor.
AbstractLinkedList
  
Template method to notify subclasses when a node is about to be removed.
LinkedSet
Property detail
_mapproperty
protected var _map:IMap

The internal map.

Constructor detail
LinkedSet()constructor
public function LinkedSet()

Creates a new LinkedSet.

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.
addItemAfterNode_internal()method 
as3_collections function addItemAfterNode_internal(leftNode:LinkedNode, item:*):Boolean

Framework internal method to add an item after an existing node.

Parameters
leftNode:LinkedNode — The existing node.
 
item:* — The item to be added after the item of the existing node.

Returns
Boolean — true, if the node has been added.

Throws
UnsupportedTypeException — If the item type does not match with the type of the internal map.
 
— If no left node is given, but the list is not empty. Developer error, should not appear.
addItemAtEnd()method 
public function addItemAtEnd(item:*):Boolean

Adds an item at the end of the linked set.

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

Parameters
item:* — The item.

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

Throws
UnsupportedTypeException — If the item type does not match with the type of the internal map.
addItemAtStart()method 
public function addItemAtStart(item:*):Boolean

Adds an item in front of the linked set.

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

Parameters
item:* — The item.

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

Throws
UnsupportedTypeException — If the item type does not match with the type of the internal map.
addItemBeforeNode_internal()method 
as3_collections function addItemBeforeNode_internal(rightNode:LinkedNode, item:*):Boolean

Framework internal method to add an item before an existing node.

Parameters
rightNode:LinkedNode — The existing node.
 
item:* — The item to be added before the item of the existing node.

Returns
Boolean — true, if the node has been added.

Throws
UnsupportedTypeException — If the item type does not match with the type of the internal map.
 
— If no right node is given, but the list is not empty. Developer error, should not appear.
clear()method 
public override function clear():void

Clears the list by removing the references to the first and last item. Cleans also the pointer reference.

May be extended in sub classes.

deregisterNode()method 
protected function deregisterNode(node:LinkedNode):void

Deregisters a node from the internal map.

Parameters
node:LinkedNode — The node to deregister.
getPointer()method 
public function getPointer(item:*):IListPointer

Returns a pointer for the linked set.

Parameters
item:* — The item, the pointer should point to initially (optional).

Returns
IListPointer — The pointer to modify the linked set.
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.
nodeAdded()method 
protected function nodeAdded(node:LinkedNode):void

Template method to notify subclasses after a new node has been added.

Parameters
node:LinkedNode — The last added node.
nodeRemoved()method 
protected function nodeRemoved():void

Commits the removal of the node, announced in willRemoveNode()

registerNode()method 
protected function registerNode(node:LinkedNode):void

Registers a node in the internal map.

Parameters
node:LinkedNode — The node to register.

Throws
UnsupportedTypeException — If the item type does not match with the type of the internal map.
removeFirstItem()method 
public function removeFirstItem():*

Removes the first item of the linked set.

Returns
* — The first item or undefined, if the set is empty.
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.
removeLastItem()method 
public function removeLastItem():*

Removes the last item of the linked set.

Returns
* — The last item or undefined, if the set is empty.
removeNode_internal()method 
as3_collections function removeNode_internal(node:LinkedNode):Boolean

Framework internal method to remove a node.

The method may be called with a null valued node.

Parameters
node:LinkedNode — The node to remove.

Returns
Boolean — true, if the node has been removed or false, if the given node is null.
toString()method 
public function toString():String

Info

Returns
String
willRemoveNode()method 
protected function willRemoveNode(node:LinkedNode):void

Template method to notify subclasses when a node is about to be removed.

We need this node to create a reference to its predecessor. After the node has been removed, this reference would be null. The subclass is in charge to cache the node's predecessor till the node is finally removed.

Parameters
node:LinkedNode — The node that will be removed soon.