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

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

A tree iterator.

Public Properties

| Property | Defined By
--- | --- | ---
|  | childData : * [read-only] Returns the item the child iterator is pointing to. | TreeIterator
|  | childNode : TreeNode [read-only] The current child node being referenced. | TreeIterator
|  | data : * Grants access to the current item being referenced by the iterator. | TreeIterator
|  | node : TreeNode The tree node being referenced. | TreeIterator

Public Methods

| Method | Defined By
--- | --- | ---
|  | TreeIterator(node:TreeNode = null) Initializes a tree iterator pointing to a given tree node. | TreeIterator
|  | appendChild(obj:*):void Appends a child node to the child list. | TreeIterator
|  | childEnd():void Moves the child iterator to the last child. | TreeIterator
|  | childStart():void Moves the child iterator to the first child. | TreeIterator
|  | childValid():Boolean Determines if the child iterator is valid. | TreeIterator
|  | 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. | TreeIterator
|  | hasNext():Boolean Checks if a next item exists. | TreeIterator
|  | insertAfterChild(obj:*):void Inserts a child node after the current child node. | TreeIterator
|  | insertBeforeChild(obj:*):void Inserts a child node before the current child node. | TreeIterator
|  | next():* Returns the current item and moves the iterator to the next item in the collection. | TreeIterator
|  | nextChild():void Moves the child iterator forward by one position. | TreeIterator
|  | postorder(node:TreeNode, process:Function):void [static] Performs a postorder traversal on a tree. | TreeIterator
|  | preorder(node:TreeNode, process:Function):void [static] Performs a preorder traversal on a tree. | TreeIterator
|  | prependChild(obj:*):void Prepends a child node to the child list. | TreeIterator
|  | prevChild():void Moves the child iterator back by one position. | TreeIterator
|  | removeChild():void Unlinks the current child node from the tree. | TreeIterator
|  | root():void Moves the iterator to the root of the tree. | TreeIterator
|  | start():void Resets the vertical iterator so that it points to the root of the tree. | TreeIterator
|  | toString():String Prints out a string representing the current object. | TreeIterator
|  | up():void Moves the iterator up by one level of the tree, so that it points to the parent of the current tree node. | TreeIterator
|  | valid():Boolean Checks if the node is valid. | TreeIterator

Property Detail

childData | property

`childData:*` [read-only]

Returns the item the child iterator is pointing to.

Implementation
`public function get childData():*`

childNode | property |

`childNode:TreeNode` [read-only]

The current child node being referenced.

Implementation
`public function get childNode():TreeNode`

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`

node | property |

`public var node:TreeNode`

The tree node being referenced.

Constructor Detail

TreeIterator | () | Constructor

`public function TreeIterator(node:TreeNode = null)`

Initializes a tree iterator pointing to a given tree node.

Parameters

| `node:TreeNode` (default = `null`)`` — The node the iterator should point to.

Method Detail

appendChild | () | method

`public function appendChild(obj:*):void`

Appends a child node to the child list.

Parameters

| `obj:*` — The data to append as a child node.

childEnd | () | method |

`public function childEnd():void`

Moves the child iterator to the last child.

childStart | () | method |

`public function childStart():void`

Moves the child iterator to the first child.

childValid | () | method |

`public function childValid():Boolean`

Determines if the child iterator is valid.

Returns

| `Boolean`

down | () | method |

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

hasNext | () | method |

`public function hasNext():Boolean`

Checks if a next item exists.

Returns

| `Boolean` — True if a next item exists, otherwise false.

insertAfterChild | () | method |

`public function insertAfterChild(obj:*):void`

Inserts a child node after the current child node.

Parameters

| `obj:*` — The data to insert as a child node.

insertBeforeChild | () | method |

`public function insertBeforeChild(obj:*):void`

Inserts a child node before the current child node.

Parameters

| `obj:*` — The data to insert as a child node.

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.

nextChild | () | method |

`public function nextChild():void`

Moves the child iterator forward by one position.

postorder | () | method |

`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

| `node:TreeNode` — The tree node to start from.
| `process:Function` — A process function applied to each traversed node.

preorder | () | method |

`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

| `node:TreeNode` — The tree node to start from.
| `process:Function` — A process function applied to each traversed node.

prependChild | () | method |

`public function prependChild(obj:*):void`

Prepends a child node to the child list.

Parameters

| `obj:*` — The data to prepend as a child node.

prevChild | () | method |

`public function prevChild():void`

Moves the child iterator back by one position.

removeChild | () | method |

`public function removeChild():void`

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

root | () | method |

`public function root():void`

Moves the iterator to the root of the tree.

start | () | method |

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

toString | () | method |

`public function toString():String`

Prints out a string representing the current object.

Returns

| `String` — A string representing the current object.

up | () | method |

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

valid | () | method |

`public function valid():Boolean`

Checks if the node is valid.

Returns

| `Boolean`

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