GODPAPER | All Packages | All Classes | Index | Frames No Frames |
SListIterator

Package | de.polygonal.ds
Class | public class SListIterator
Inheritance | SListIterator Object
Implements | Iterator

A singly 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

| Property | Defined By
--- | --- | ---
|  | data : * Grants access to the current item being referenced by the iterator. | SListIterator
|  | list : SLinkedList The list this iterator uses. | SListIterator
|  | node : SListNode The node the iterator is pointing to. | SListIterator

Public Methods

| Method | Defined By
--- | --- | ---
|  | SListIterator(list:SLinkedList = null, node:SListNode = null) Creates a new SListIterator instance pointing to a given node. | SListIterator
|  | end():void Moves the iterator to the tail node. | SListIterator
|  | forth():void Moves the iterator to the next node. | SListIterator
|  | hasNext():Boolean Checks if a next item exists. | SListIterator
|  | next():* Returns the current item and moves the iterator to the next item in the collection. | SListIterator
|  | remove():Boolean Removes the node the iterator is pointing to. | SListIterator
|  | start():void Moves the iterator to the first item in the collection. | SListIterator
|  | toString():String Prints out a string representing the current object. | SListIterator
|  | valid():Boolean Checks if the current referenced node is valid. | SListIterator

Property Detail

data | property

`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`

list | property |

`public var list:SLinkedList`

The list this iterator uses.

node | property |

`public var node:SListNode`

The node the iterator is pointing to.

Constructor Detail

SListIterator | () | Constructor

`public function SListIterator(list:SLinkedList = null, node:SListNode = null)`

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

Parameters

| `list:SLinkedList` (default = `null`)`` — The linked list the iterator should handle.
| `node:SListNode` (default = `null`)`` — The iterator's starting node.

Method Detail

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.

Thu Jan 16 2014, 01:11 PM +08:00