SListIterator

SListIterator

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.

Summary
SListIteratorA singly linked list iterator.
Variables
nodeThe node the iterator is pointing to.
listThe list this iterator uses.
Functions
SListIteratorCreates a new SListIterator instance pointing to a given node.
start@inheritDoc
next@inheritDoc
hasNext@inheritDoc
Properties
data@inheritDoc
data@private
Functions
endMoves the iterator to the tail node.
forthMoves the iterator to the next node.
validChecks if the current referenced node is valid.
removeRemoves the node the iterator is pointing to.
toStringPrints out a string representing the current object.

Variables

node

public var node: SListNode

The node the iterator is pointing to.

list

public var list: SLinkedList

The list this iterator uses.

Functions

SListIterator

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

listThe linked list the iterator should handle.
nodeThe iterator’s starting node. 

start

public function start():void

@inheritDoc

next

public function next():*

@inheritDoc

hasNext

public function hasNext():Boolean

@inheritDoc

Properties

data

public function get data():*

@inheritDoc

data

public function set data(obj: *):void

@private

Functions

end

public function end():void

Moves the iterator to the tail node.

forth

public function forth():void

Moves the iterator to the next node.

valid

public function valid():Boolean

Checks if the current referenced node is valid.

Returns

True if the node exists, otherwise false. 

remove

public function remove():Boolean

Removes the node the iterator is pointing to.

Returns

True if the removal succeeded, otherwise false. 

toString

public function toString():String

Prints out a string representing the current object.

Returns

A string representing the current object. 

A ‘java-style’ iterator interface.
public var node: SListNode
The node the iterator is pointing to.
public var list: SLinkedList
The list this iterator uses.
public function SListIterator(list: SLinkedList = null,
node: SListNode = null)
Creates a new SListIterator instance pointing to a given node.
public function start():void
@inheritDoc
public function next():*
@inheritDoc
public function hasNext():Boolean
@inheritDoc
public function get data():*
@inheritDoc
public function end():void
Moves the iterator to the tail node.
public function forth():void
Moves the iterator to the next node.
public function valid():Boolean
Checks if the current referenced node is valid.
public function remove():Boolean
Removes the node the iterator is pointing to.
public function toString():String
Prints out a string representing the current object.
Close