| Package | de.polygonal.ds |
| Class | public class DLinkedList |
| Inheritance | DLinkedList Object |
| Implements | Collection |
| Property | Defined By | ||
|---|---|---|---|
| head : DListNode
The head node being referenced. | DLinkedList | ||
| size : int [read-only]
The total number of items. | DLinkedList | ||
| tail : DListNode
The tail node being referenced. | DLinkedList | ||
| Method | Defined By | ||
|---|---|---|---|
DLinkedList(... args)
Initializes an empty list. | DLinkedList | ||
Appends items to the list. | DLinkedList | ||
clear():void
Clears all items. | DLinkedList | ||
concat(... args):DLinkedList
Concatenates the current list with all lists specified in the
parameters and returns a new linked list. | DLinkedList | ||
contains(obj:*):Boolean
Determines if the collection contains a given item. | DLinkedList | ||
dump():String
Prints out all elements (for debug/demo purposes). | DLinkedList | ||
Initializes an iterator object pointing to the first item in the
collection. | DLinkedList | ||
Creates a list iterator object pointing to the first node in the list. | DLinkedList | ||
Inserts an item after a given iterator or appends it if the
iterator is invalid. | DLinkedList | ||
Inserts an item before a given iterator or appends it
if the iterator is invalid. | DLinkedList | ||
isEmpty():Boolean
Checks if the collection is empty. | DLinkedList | ||
join(sep:*):String
Converts the data in the linked list to strings, inserts the given
separator between the elements, concatenates them, and returns the
resulting string. | DLinkedList | ||
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. | DLinkedList | ||
merge(... args):void
Merges the current list with all lists specified in the paramaters. | DLinkedList | ||
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. | DLinkedList | ||
popDown():void
Removes and prepends the tail node to the head. | DLinkedList | ||
Prepends items to the list. | DLinkedList | ||
remove(itr:DListIterator):Boolean
Removes the node the iterator is pointing to while moving the
iterator to the next node. | DLinkedList | ||
removeHead():*
Removes the head of the list and returns the head's data or null
if the list is empty. | DLinkedList | ||
removeTail():*
Removes the tail of the list and returns the tail's data or null
if the list is empty. | DLinkedList | ||
reverse():void
Reverses the linked list in place. | DLinkedList | ||
shiftUp():void
Removes and appends the head node to the tail. | DLinkedList | ||
sort(... sortOptions):void
Sorts the list. | DLinkedList | ||
Adds nodes to and removes nodes from the list. | DLinkedList | ||
toArray():Array
Converts the collection into an array. | DLinkedList | ||
toString():String
Prints out a string representing the current object. | DLinkedList | ||
| head | property |
public var head:DListNodeThe head node being referenced. This is the first node in the list.
| size | property |
size:int [read-only] The total number of items.
public function get size():int| tail | property |
public var tail:DListNodeThe tail node being referenced. This is the last node in the list.
| DLinkedList | () | Constructor |
public function DLinkedList(... args)Initializes an empty list. You can add initial items by passing them as a comma-separated list of values.
Parameters... args — A list of comma-separated values to append.
|
| append | () | method |
public function append(... args):DListNodeAppends items to the list.
Parameters
... args — A list of comma-separated values to append.
|
DListNode — A DListNode object wrapping the data. If multiple values are
added, the returned node represents the node that stores the
data of the first argument.
|
| clear | () | method |
public function clear():voidClears all items.
| concat | () | method |
public function concat(... args):DLinkedListConcatenates 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.
Parameters
... args — A list of one or more comma-separated DLinkedList objects.
|
DLinkedList — A copy of the current list which also stores the values from
the passed lists.
|
See also
| contains | () | method |
public function contains(obj:*):BooleanDetermines if the collection contains a given item.
Parameters
obj:* — The item to search for.
|
Boolean — True if the item exists, otherwise false.
|
| dump | () | method |
public function dump():StringPrints out all elements (for debug/demo purposes).
ReturnsString — A human-readable representation of the structure.
|
| getIterator | () | method |
public function getIterator():IteratorInitializes an iterator object pointing to the first item in the collection.
ReturnsIterator — An iterator object.
|
| getListIterator | () | method |
public function getListIterator():DListIteratorCreates a list iterator object pointing to the first node in the list.
ReturnsDListIterator |
| insertAfter | () | method |
public function insertAfter(itr:DListIterator, obj:*):DListNodeInserts an item after a given iterator or appends it if the iterator is invalid.
Parameters
itr:DListIterator — An iterator object pointing to the node after which the
given data is inserted.
| |
obj:* — The data to insert.
|
DListNode — A doubly linked list node wrapping the data.
|
| insertBefore | () | method |
public function insertBefore(itr:DListIterator, obj:*):DListNodeInserts an item before a given iterator or appends it if the iterator is invalid.
Parameters
itr:DListIterator — An iterator object pointing to the node before which the
given data is inserted.
| |
obj:* — The data to insert.
|
DListNode — A doubly linked list node wrapping the data.
|
| isEmpty | () | method |
public function isEmpty():BooleanChecks if the collection is empty.
ReturnsBoolean — True if empty, otherwise false.
|
| join | () | method |
public function join(sep:*):StringConverts the data in the linked list to strings, inserts the given separator between the elements, concatenates them, and returns the resulting string.
Parameters
sep:* |
String — A string consisting of the data converted to strings and
separated by the specified parameter.
|
| lastNodeOf | () | method |
public function lastNodeOf(obj:*, from:DListIterator = null):DListIteratorSearches 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.
Parameters
obj:* — The item to search for.
| |
from:DListIterator (default = null) — A DListIterator object pointing to the node in the list
from which to start searching for the item.
|
DListIterator — 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.
|
| merge | () | method |
public function merge(... args):voidMerges 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.
Parameters
... args — A list of one or more comma-separated DLinkedList objects.
|
See also
| nodeOf | () | method |
public function nodeOf(obj:*, from:DListIterator = null):DListIteratorSearches 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.
Parameters
obj:* — The item to search for.
| |
from:DListIterator (default = null) — A DListIterator object pointing to the node in the list
from which to start searching for the item.
|
DListIterator — 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.
|
| popDown | () | method |
public function popDown():voidRemoves and prepends the tail node to the head.
| prepend | () | method |
public function prepend(... args):DListNodePrepends items to the list.
Parameters
... args — A list of comma-separated values to prepend.
|
DListNode — A DListNode object wrapping the data. If multiple values are
added, the returned node represents the node that stores the
data of the first argument.
|
| remove | () | method |
public function remove(itr:DListIterator):BooleanRemoves the node the iterator is pointing to while moving the iterator to the next node.
Parameters
itr:DListIterator — An iterator object pointing to the node to remove.
|
Boolean — True if the removal succeeded, otherwise false.
|
| removeHead | () | method |
public function removeHead():*Removes the head of the list and returns the head's data or null if the list is empty.
Returns* — The data which was associated with the removed node.
|
| removeTail | () | method |
public function removeTail():*Removes the tail of the list and returns the tail's data or null if the list is empty.
Returns* — The data which was associated with the removed node.
|
| reverse | () | method |
public function reverse():voidReverses the linked list in place.
| shiftUp | () | method |
public function shiftUp():voidRemoves and appends the head node to the tail.
| sort | () | method |
public function sort(... sortOptions):voidSorts 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.
Parameters
... sortOptions |
See also
| splice | () | method |
public function splice(start:DListIterator, deleteCount:uint = 0xffffffff, ... args):DLinkedListAdds nodes to and removes nodes from the list. This method directly modifies the list without making a copy.
Parameters
start:DListIterator — 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:uint (default = 0xffffffff) — 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.
|
DLinkedList |
| toArray | () | method |
public function toArray():ArrayConverts the collection into an array.
ReturnsArray — An array.
|
| toString | () | method |
public function toString():StringPrints out a string representing the current object.
ReturnsString — A string representing the current object.
|