DLinkedList |
A doubly linked list.
DLinkedList | A doubly linked list. |
Variables | |
head | The head node being referenced. |
tail | The tail node being referenced. |
Functions | |
DLinkedList | Initializes an empty list. |
append | Appends items to the list. |
prepend | Prepends items to the list. |
insertAfter | Inserts an item after a given iterator or appends it if the iterator is invalid. |
insertBefore | Inserts an item before a given iterator or appends it if the iterator is invalid. |
remove | Removes the node the iterator is pointing to while moving the iterator to the next node. |
removeHead | Removes the head of the list and returns the head’s data or null if the list is empty. |
removeTail | Removes the tail of the list and returns the tail’s data or null if the list is empty. |
merge | Merges the current list with all lists specified in the paramaters. |
concat | Concatenates the current list with all lists specified in the parameters and returns a new linked list. |
sort | Sorts the list. |
nodeOf | Searches for an item in the list by using strict equality (===) and returns an iterator pointing to the node containing the item or null if the item was not found. |
lastNodeOf | Searches for an item in the list, working backward from the last item, by using strict equality (===) and returns an iterator pointing to the node containing the item or null if the item was not found. |
splice | Adds nodes to and removes nodes from the list. |
shiftUp | Removes and appends the head node to the tail. |
popDown | Removes and prepends the tail node to the head. |
reverse | Reverses the linked list in place. |
join | Converts the data in the linked list to strings, inserts the given separator between the elements, concatenates them, and returns the resulting string. |
contains | @inheritDoc |
clear | @inheritDoc |
getIterator | @inheritDoc |
getListIterator | Creates a list iterator object pointing to the first node in the list. |
Properties | |
size | @inheritDoc |
Functions | |
isEmpty | @inheritDoc |
toArray | @inheritDoc |
toString | Prints out a string representing the current object. |
dump | Prints out all elements (for debug/demo purposes). |
public function insertAfter( itr: DListIterator, obj: * ):DListNode
Inserts an item after a given iterator or appends it if the iterator is invalid.
itr | An iterator object pointing to the node after which the given data is inserted. |
obj | The data to insert. |
A doubly linked list node wrapping the data.
public function insertBefore( itr: DListIterator, obj: * ):DListNode
Inserts an item before a given iterator or appends it if the iterator is invalid.
itr | An iterator object pointing to the node before which the given data is inserted. |
obj | The data to insert. |
A doubly linked list node wrapping the data.
public function merge( ...args ):void
Merges the current list with all lists specified in the paramaters. The list is directly modified to reflect the changes. Due to the rearrangement of the node pointers all passed lists become invalid and should be discarded.
args | A list of one or more comma-separated DLinkedList objects. |
public function concat( ...args ):DLinkedList
Concatenates the current list with all lists specified in the parameters and returns a new linked list. The original list and all passed lists are left unchanged.
args | A list of one or more comma-separated DLinkedList objects. |
A copy of the current list which also stores the values from the passed lists.
public function sort( ...sortOptions ):void
Sorts the list. The default sorting algorithm is ‘mergesort’. If the LinkedList.INSERTION_SORT flag is used, the list is sorted using the insertion sort algorithm instead, which is much faster for nearly sorted lists.
sortOptions |
//www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html (http:)
public function nodeOf( obj: *, from: DListIterator = null ):DListIterator
Searches for an item in the list by using strict equality (===) and returns an iterator pointing to the node containing the item or null if the item was not found.
param | obj The item to search for. |
param | from A DListIterator object pointing to the node in the list from which to start searching for the item. |
An DListIterator object pointing to the node with the found item or null if no item exists matching the input data or the iterator is invalid.
public function lastNodeOf( obj: *, from: DListIterator = null ):DListIterator
Searches for an item in the list, working backward from the last item, by using strict equality (===) and returns an iterator pointing to the node containing the item or null if the item was not found.
param | obj The item to search for. |
param | from A DListIterator object pointing to the node in the list from which to start searching for the item. |
A DListIterator object pointing to the node with the found item or null if no item exists matching the input data or the iterator is invalid.
public function splice( start: DListIterator, deleteCount: uint = 0xffffffff, ...args ):DLinkedList
Adds nodes to and removes nodes from the list. This method directly modifies the list without making a copy.
start | A DListIterator object pointing to the node where the insertion or deletion begins. The iterator is updated so it still points to the original node, even if the node now belongs to another list. |
deleteCount | An integer that specifies the number of nodes to delete. This number includes the node referenced by the iterator. If no value is specified for the deleteCount parameter, the method deletes all of the nodes from the start iterator to the tail of the list. If the value is 0, no nodes are deleted. |
args | Specifies the values to insert into the list, starting at the iterator’s node. |
return | A DLinkedList object containing the nodes that were removed from the original list or null if the iterator is invalid. |
The head node being referenced.
public var head: DListNode
The tail node being referenced.
public var tail: DListNode
Initializes an empty list.
public function DLinkedList( ...args )
Appends items to the list.
public function append( ...args ):DListNode
Prepends items to the list.
public function prepend( ...args ):DListNode
Inserts an item after a given iterator or appends it if the iterator is invalid.
public function insertAfter( itr: DListIterator, obj: * ):DListNode
Inserts an item before a given iterator or appends it if the iterator is invalid.
public function insertBefore( itr: DListIterator, obj: * ):DListNode
Removes the node the iterator is pointing to while moving the iterator to the next node.
public function remove( itr: DListIterator ):Boolean
Removes the head of the list and returns the head’s data or null if the list is empty.
public function removeHead():*
Removes the tail of the list and returns the tail’s data or null if the list is empty.
public function removeTail():*
Merges the current list with all lists specified in the paramaters.
public function merge( ...args ):void
Concatenates the current list with all lists specified in the parameters and returns a new linked list.
public function concat( ...args ):DLinkedList
Sorts the list.
public function sort( ...sortOptions ):void
Searches for an item in the list by using strict equality (===) and returns an iterator pointing to the node containing the item or null if the item was not found.
public function nodeOf( obj: *, from: DListIterator = null ):DListIterator
Searches for an item in the list, working backward from the last item, by using strict equality (===) and returns an iterator pointing to the node containing the item or null if the item was not found.
public function lastNodeOf( obj: *, from: DListIterator = null ):DListIterator
Adds nodes to and removes nodes from the list.
public function splice( start: DListIterator, deleteCount: uint = 0xffffffff, ...args ):DLinkedList
Removes and appends the head node to the tail.
public function shiftUp():void
Removes and prepends the tail node to the head.
public function popDown():void
Reverses the linked list in place.
public function reverse():void
Converts the data in the linked list to strings, inserts the given separator between the elements, concatenates them, and returns the resulting string.
public function join( sep: * ):String
@inheritDoc
public function contains( obj: * ):Boolean
@inheritDoc
public function clear():void
@inheritDoc
public function getIterator():Iterator
Creates a list iterator object pointing to the first node in the list.
public function getListIterator():DListIterator
@inheritDoc
public function get size():int
@inheritDoc
public function isEmpty():Boolean
@inheritDoc
public function toArray():Array
Prints out a string representing the current object.
public function toString():String
Prints out all elements (for debug/demo purposes).
public function dump():String