TreeIterator

TreeIterator

A tree iterator.

Summary
TreeIteratorA tree iterator.
Functions
preorderPerforms a preorder traversal on a tree.
postorderPerforms a postorder traversal on a tree.
Variables
nodeThe tree node being referenced.
Functions
TreeIteratorInitializes a tree iterator pointing to a given tree node.
hasNext@inheritDoc
next@inheritDoc
startResets the vertical iterator so that it points to the root of the tree.
Properties
data@inheritDoc
data@inheritDoc
childNodeThe current child node being referenced.
childDataReturns the item the child iterator is pointing to.
Functions
validChecks if the node is valid.
rootMoves the iterator to the root of the tree.
upMoves the iterator up by one level of the tree, so that it points to the parent of the current tree node.
downMoves the iterator down by one level of the tree, so that it points to the first child of the current tree node.
nextChildMoves the child iterator forward by one position.
prevChildMoves the child iterator back by one position.
childStartMoves the child iterator to the first child.
childEndMoves the child iterator to the last child.
childValidDetermines if the child iterator is valid.
appendChildAppends a child node to the child list.
prependChildPrepends a child node to the child list.
insertBeforeChildInserts a child node before the current child node.
insertAfterChildInserts a child node after the current child node.
removeChildUnlinks the current child node from the tree.
toStringPrints out a string representing the current object.

Functions

preorder

public static function preorder(node: TreeNode,
process: Function):void

Performs a preorder traversal on a tree.  This processes the current tree node before its children.

Parameters

nodeThe tree node to start from.
processA process function applied to each traversed node. 

postorder

public static function postorder(node: TreeNode,
process: Function):void

Performs a postorder traversal on a tree.  This processes the current node after its children.

Parameters

nodeThe tree node to start from.
processA process function applied to each traversed node. 

Variables

node

public var node: TreeNode

The tree node being referenced.

Functions

TreeIterator

public function TreeIterator(node: TreeNode = null)

Initializes a tree iterator pointing to a given tree node.

Parameters

nodeThe node the iterator should point to. 

hasNext

public function hasNext():Boolean

@inheritDoc

next

public function next():*

@inheritDoc

start

public function start():void

Resets the vertical iterator so that it points to the root of the tree.  Also make sures the horizontal iterator points to the first child.

Properties

data

public function get data():*

@inheritDoc

data

public function set data(obj: *):void

@inheritDoc

childNode

public function get childNode():TreeNode

The current child node being referenced.

childData

public function get childData():*

Returns the item the child iterator is pointing to.

Functions

valid

public function valid():Boolean

Checks if the node is valid.

root

public function root():void

Moves the iterator to the root of the tree.

up

public function up():void

Moves the iterator up by one level of the tree, so that it points to the parent of the current tree node.

down

public function down():void

Moves the iterator down by one level of the tree, so that it points to the first child of the current tree node.

nextChild

public function nextChild():void

Moves the child iterator forward by one position.

prevChild

public function prevChild():void

Moves the child iterator back by one position.

childStart

public function childStart():void

Moves the child iterator to the first child.

childEnd

public function childEnd():void

Moves the child iterator to the last child.

childValid

public function childValid():Boolean

Determines if the child iterator is valid.

appendChild

public function appendChild(obj: *):void

Appends a child node to the child list.

Parameters

objThe data to append as a child node. 

prependChild

public function prependChild(obj: *):void

Prepends a child node to the child list.

Parameters

objThe data to prepend as a child node. 

insertBeforeChild

public function insertBeforeChild(obj: *):void

Inserts a child node before the current child node.

Parameters

objThe data to insert as a child node. 

insertAfterChild

public function insertAfterChild(obj: *):void

Inserts a child node after the current child node.

Parameters

objThe data to insert as a child node. 

removeChild

public function removeChild():void

Unlinks the current child node from the tree.  This does not delete the node.

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 static function preorder(node: TreeNode,
process: Function):void
Performs a preorder traversal on a tree.
public static function postorder(node: TreeNode,
process: Function):void
Performs a postorder traversal on a tree.
public var node: TreeNode
The tree node being referenced.
public function TreeIterator(node: TreeNode = null)
Initializes a tree iterator pointing to a given tree node.
public function hasNext():Boolean
@inheritDoc
public function next():*
@inheritDoc
public function start():void
Resets the vertical iterator so that it points to the root of the tree.
public function get data():*
@inheritDoc
public function get childNode():TreeNode
The current child node being referenced.
public function get childData():*
Returns the item the child iterator is pointing to.
public function valid():Boolean
Checks if the node is valid.
public function root():void
Moves the iterator to the root of the tree.
public function up():void
Moves the iterator up by one level of the tree, so that it points to the parent of the current tree node.
public function down():void
Moves the iterator down by one level of the tree, so that it points to the first child of the current tree node.
public function nextChild():void
Moves the child iterator forward by one position.
public function prevChild():void
Moves the child iterator back by one position.
public function childStart():void
Moves the child iterator to the first child.
public function childEnd():void
Moves the child iterator to the last child.
public function childValid():Boolean
Determines if the child iterator is valid.
public function appendChild(obj: *):void
Appends a child node to the child list.
public function prependChild(obj: *):void
Prepends a child node to the child list.
public function insertBeforeChild(obj: *):void
Inserts a child node before the current child node.
public function insertAfterChild(obj: *):void
Inserts a child node after the current child node.
public function removeChild():void
Unlinks the current child node from the tree.
public function toString():String
Prints out a string representing the current object.
Close