TreeEnumerator
Kind of class: | public class |
---|---|
Package: | |
Inherits from: |
|
Classpath: | org.asaplibrary.data.tree.TreeEnumerator |
File last modified: | Wednesday, 11 May 2011, 18:33:57 |
Straightforward enumeration (iterator) class for Tree objects. TreeEnumerator has one way of iterating: forward (getNextObject).
Usage
-
var root:Tree = new Tree("root"); var child:Tree = root.addChild("A"); var e:TreeEnumerator = new TreeEnumerator(root); trace(e.getCurrentObject()); // null var node:Tree = e.getNextObject(); trace(e.getCurrentObject()); // Tree: root node = e.getNextObject(); trace(e.getCurrentObject()); // Tree: "A" node = e.getNextObject(); trace(e.getCurrentObject()); // null
Summary
Constructor
-
TreeEnumerator
(inRoot:Tree)
- Creates a new enumerator.
Instance methods
-
getCurrentObject
() : *
- setCurrentObject (inTreeNode:Tree) : void
- Moves the enumerator to Tree node inTreeNode.
- getNextObject () : *
- Moves the enumerator to the next position and returns its value.
- reset () : void
- Resets the enumerator to the start.
Instance methods inherited from BaseEnumerator- setCurrentObject (inTreeNode:Tree) : void
Constructor
TreeEnumerator
function TreeEnumerator(inRoot:Tree)
Creates a new enumerator.
Parameters
inRoot:Tree (root node) to enumerate
Instance properties
root
root:Tree(read,write)
The enumerated Tree. Sets a new node as root node.
Parameters
inRoot:the new root node
Instance methods
getCurrentObject
override function getCurrentObject() : *
Retrieves the object at the current pointer position. →
Overrides
Returns
- The current Tree node.
getNextObject
override function getNextObject() : *
Moves the enumerator to the next position and returns its value.
Overrides
Returns
- The Tree node at the new position.
reset
override function reset() : void
Resets the enumerator to the start.
Overrides
setCurrentObject
function setCurrentObject(inTreeNode:Tree) : void
Moves the enumerator to Tree node inTreeNode.
Parameters
inTreeNode:the node to start enumerating from