Packagede.polygonal.ds
Classpublic class DListIterator
InheritanceDListIterator Inheritance Object
Implements Iterator

A doubly linked list iterator. Provides some additional methods useful when dealing with linked lists. Be careful when using them together with the methods implemented through the Iterator interface since they both work differently.



Public Properties
 PropertyDefined By
  data : *
Grants access to the current item being referenced by the iterator.
DListIterator
  list : DLinkedList
The list this iterator uses.
DListIterator
  node : DListNode
The node the iterator is currently pointing to.
DListIterator
Public Methods
 MethodDefined By
  
Creates a new DListIterator instance pointing to a given node.
DListIterator
  
back():void
Moves the iterator to the previous node.
DListIterator
  
end():void
Moves the iterator to the tail node.
DListIterator
  
forth():void
Moves the iterator to the next node.
DListIterator
  
hasNext():Boolean
Checks if a next item exists.
DListIterator
  
next():*
Returns the current item and moves the iterator to the next item in the collection.
DListIterator
  
remove():Boolean
Removes the node the iterator is pointing to.
DListIterator
  
start():void
Moves the iterator to the first item in the collection.
DListIterator
  
toString():String
Prints out a string representing the current object.
DListIterator
  
valid():Boolean
Checks if the current referenced node is valid.
DListIterator
Property Detail
dataproperty
data:*

Grants access to the current item being referenced by the iterator. This provides a quick way to read or write the current data.


Implementation
    public function get data():*
    public function set data(value:any):void
listproperty 
public var list:DLinkedList

The list this iterator uses.

nodeproperty 
public var node:DListNode

The node the iterator is currently pointing to.

Constructor Detail
DListIterator()Constructor
public function DListIterator(list:DLinkedList, node:DListNode = null)

Creates a new DListIterator instance pointing to a given node. Usually created by invoking DLinkedList.getIterator().

Parameters
list:DLinkedList — The linked list the iterator should handle.
 
node:DListNode (default = null) — The iterator's starting node.
Method Detail
back()method
public function back():void

Moves the iterator to the previous node.

end()method 
public function end():void

Moves the iterator to the tail node.

forth()method 
public function forth():void

Moves the iterator to the next node.

hasNext()method 
public function hasNext():Boolean

Checks if a next item exists.

Returns
Boolean — True if a next item exists, otherwise false.
next()method 
public function next():*

Returns the current item and moves the iterator to the next item in the collection. Note that the next() method returns the first item in the collection when it's first called.

Returns
* — The next item in the collection.
remove()method 
public function remove():Boolean

Removes the node the iterator is pointing to.

Returns
Boolean — True if the removal succeeded, otherwise false.
start()method 
public function start():void

Moves the iterator to the first item in the collection.

toString()method 
public function toString():String

Prints out a string representing the current object.

Returns
String — A string representing the current object.
valid()method 
public function valid():Boolean

Checks if the current referenced node is valid.

Returns
Boolean — True if the node exists, otherwise false.