Tree
Kind of class: | public class |
---|---|
Package: | |
Inherits from: |
|
Classpath: | org.asaplibrary.data.tree.Tree |
File last modified: | Sunday, 15 May 2011, 21:44:14 |
All sorts of information is hierarchical and can be represented by a tree structure: websites, photo albums, topic knowledge, etcetera.
This Tree class is a position tree: each tree node has exactly one parent node and can have multiple children. The root node has no parent.
Tree nodes can be added as sub-Tree objects.
Use a TreeEnumerator to traverse the tree.
Usage
-
var root:Tree = new Tree("root"); var data:Object = {order:0;}; var child:Tree = root.addChild("A", data);
Summary
Instance properties
Instance methods
-
addChildNode
(inTree:Tree) : void
- Adds an existing Tree node as child.
-
addChild
(inName:String, inData:Object = null) : Tree
- Creates a new Tree node and adds it as child.
-
printNodes
(inOffsetString:String = "") : void
- Prints info on this node and its children.
Instance properties
children
children:Array(read)
The list of child nodes.
data
data:Object(read,write)
Generic data container.
name
name:String(read,write)
The identifier name; this name should be unique and without spaces.
Instance methods
addChild
function addChild(inName:String,
inData:Object = null) : Tree
Creates a new Tree node and adds it as child.
Parameters
inName:the identifier name; this name should be unique and without spaces.
inData:(optional) data container
addChildNode
function addChildNode(inTree:Tree) : void
Adds an existing Tree node as child.
Parameters
inTree:child node to add
printNodes
function printNodes(inOffsetString:String = "") : void
Prints info on this node and its children.