| Package | as3.collections |
| Class | public class LinkedSet |
| Inheritance | LinkedSet AbstractLinkedList |
| Implements | ILinkedSet |
| Subclasses | LinkedSetFx |
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 operationsSee also
| Property | Defined by | ||
|---|---|---|---|
![]() | _first : LinkedNode
The first item of the linked list.
| AbstractLinkedList | |
![]() | _last : LinkedNode
The last item of the linked list.
| AbstractLinkedList | |
| _map : IMap
The internal map.
| LinkedSet | ||
![]() | _numItems : uint = 0
The size of the sequence.
| AbstractLinkedList | |
![]() | _pointer : AbstractPointer
The singleton linked list pointer.
| AbstractLinkedList | |
| Method | Defined 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 | ||
![]() |
getFirstItem():*
Returns the first item of the linked list.
| AbstractLinkedList | |
![]() |
getIterator(cursor:uint = 0):IIterator
Returns an iterator starting at the specified position.
| AbstractLinkedList | |
![]() |
getLastItem():*
Returns the last item of the linked list.
| AbstractLinkedList | |
|
getPointer(item:*):IListPointer
Returns a pointer for the linked set.
| LinkedSet | ||
|
hasItem(item:*):Boolean
Tests, if an item is contained by the set.
| LinkedSet | ||
|
removeFirstItem():*
Removes the first item of the linked set.
| LinkedSet | ||
|
removeItem(item:*):Boolean
Removes an item from the set.
| LinkedSet | ||
|
removeLastItem():*
Removes the last item of the linked set.
| LinkedSet | ||
![]() |
reverse():void
Reverses the linked list order.
| AbstractLinkedList | |
![]() |
sort(comparator:IComparator):void
Sorts the linked list by a given criterion.
| AbstractLinkedList | |
![]() |
toArray():Array
Returns an array of all items in the present order.
| AbstractLinkedList | |
|
toString():String
Info
| LinkedSet | ||
| Method | Defined by | ||
|---|---|---|---|
![]() |
addFirstNode(node:LinkedNode):void
Adds the first node to an empty list.
| AbstractLinkedList | |
![]() |
Inserts a new node after an existing one.
| AbstractLinkedList | |
![]() |
addNodeAtEnd(node:LinkedNode):void
Inserts a new node at the end of the sequence.
| AbstractLinkedList | |
![]() |
addNodeAtStart(node:LinkedNode):void
Inserts a new node at the start of the sequence.
| AbstractLinkedList | |
![]() |
Inserts a new node before an existing one.
| AbstractLinkedList | |
|
deregisterNode(node:LinkedNode):void
Deregisters a node from the internal map.
| LinkedSet | ||
![]() |
getNodeAt(index:uint):LinkedNode
Returns the node at a specific position.
| AbstractLinkedList | |
![]() |
insertionSort(comparator:IComparator):void
Insertion sort algorithm.
| AbstractLinkedList | |
![]() |
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 | ||
|
registerNode(node:LinkedNode):void
Registers a node in the internal map.
| LinkedSet | ||
![]() |
unlinkFirstNode():void
Unlinks the first node of the sequence.
| AbstractLinkedList | |
![]() |
unlinkLastNode():void
Unlinks the last node of the sequence.
| AbstractLinkedList | |
![]() |
unlinkNode(node:LinkedNode):void
Unlinks a node and connects predecessor with successor.
| AbstractLinkedList | |
|
willRemoveNode(node:LinkedNode):void
Template method to notify subclasses when a node is about to be removed.
| LinkedSet | ||
| _map | property |
protected var _map:IMapThe internal map.
| LinkedSet | () | constructor |
public function LinkedSet()Creates a new LinkedSet.
| addItem | () | method |
public function addItem(item:*):BooleanAdds an item to the set.
Trying to add an item twice leaves the set untouched and returns false.
Parametersitem:* — The item.
|
Boolean — true, if the item has been added, else false.
|
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:*):BooleanFramework internal method to add an item after an existing node.
ParametersleftNode:LinkedNode — The existing node.
|
|
item:* — The item to be added after the item of the existing node.
|
Boolean — true, if the node has been added.
|
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:*):BooleanAdds an item at the end of the linked set.
Trying to add an existing item leaves the set untouched and returns false.
Parametersitem:* — The item.
|
Boolean — true, if the item has been added.
|
UnsupportedTypeException — If the item type does not match
with the type of the internal map.
|
| addItemAtStart | () | method |
public function addItemAtStart(item:*):BooleanAdds an item in front of the linked set.
Trying to add an existing item leaves the set untouched and returns false.
Parametersitem:* — The item.
|
Boolean — true, if the item has been added.
|
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:*):BooleanFramework internal method to add an item before an existing node.
ParametersrightNode:LinkedNode — The existing node.
|
|
item:* — The item to be added before the item of the existing node.
|
Boolean — true, if the node has been added.
|
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():voidClears 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):voidDeregisters a node from the internal map.
Parametersnode:LinkedNode — The node to deregister.
|
| getPointer | () | method |
public function getPointer(item:*):IListPointerReturns a pointer for the linked set.
Parametersitem:* — The item, the pointer should point to initially (optional).
|
IListPointer —
The pointer to modify the linked set.
|
| hasItem | () | method |
public function hasItem(item:*):BooleanTests, if an item is contained by the set.
Parametersitem:* — The item to test.
|
Boolean — true, if the item is contained, else false.
|
| nodeAdded | () | method |
protected function nodeAdded(node:LinkedNode):voidTemplate method to notify subclasses after a new node has been added.
Parametersnode:LinkedNode — The last added node.
|
| nodeRemoved | () | method |
protected function nodeRemoved():voidCommits the removal of the node, announced in willRemoveNode()
| registerNode | () | method |
protected function registerNode(node:LinkedNode):voidRegisters a node in the internal map.
Parametersnode:LinkedNode — The node to register.
|
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:*):BooleanRemoves an item from the set.
Trying to remove an item, which is not contained by the set, leaves the set untouched and returns false.
Parametersitem:* — The item to remove.
|
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):BooleanFramework internal method to remove a node.
The method may be called with a null valued node.
Parametersnode:LinkedNode — The node to remove.
|
Boolean — true, if the node has been removed or false, if the given node is null.
|
| toString | () | method |
public function toString():StringInfo
ReturnsString |
| willRemoveNode | () | method |
protected function willRemoveNode(node:LinkedNode):voidTemplate 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.
Parametersnode:LinkedNode — The node that will be removed soon.
|