TreeNode

TreeNode

A tree node for building a tree data structure.

Every tree node has a linked list of child nodes and a pointer to its parent node.  Note that a tree data structure is build of TreeNode objects, so there is no class that manages a tree structure.

Summary
TreeNodeA tree node for building a tree data structure.
Variables
parentThe parent node being referenced.
childrenA list of child nodes being referenced.
dataThe data being referened.
Functions and Properties
TreeNodeCreates a tree node.
sizeCounts the total number of tree nodes starting from the current tree node.
isRootChecks if the tree node is a root node.
isLeafChecks if the tree node is a leaf node.
hasChildrenChecks if the tree node has child nodes.
hasSiblingsChecks if the tree node has siblings.
isEmptyChecks is the tree node is empty (has no children).
depthComputes the depth of the tree, starting from this node.
numChildrenThe total number of children.
numSiblingsThe total number of siblings.
contains@inheritDoc
clear@inheritDoc
getIterator@inheritDoc
getTreeIteratorCreates a tree iterator pointing at this tree node.
toArray@inheritDoc
toStringPrints out a string representing the current object.
dumpPrints out all elements (for debug/demo purposes).

Variables

parent

public var parent: TreeNode

The parent node being referenced.

children

public var children: DLinkedList

A list of child nodes being referenced.

data

public var data: *

The data being referened.

Functions and Properties

TreeNode

public function TreeNode(obj: * = null,
parent: TreeNode = null)

Creates a tree node.

Parameters

objThe data to store inside the node.
parentThe node’s parent. 

size

public function get size():int

Counts the total number of tree nodes starting from the current tree node.

isRoot

public function isRoot():Boolean

Checks if the tree node is a root node.

isLeaf

public function isLeaf():Boolean

Checks if the tree node is a leaf node.

hasChildren

public function hasChildren():Boolean

Checks if the tree node has child nodes.

hasSiblings

public function hasSiblings():Boolean

Checks if the tree node has siblings.

isEmpty

public function isEmpty():Boolean

Checks is the tree node is empty (has no children).

depth

public function get depth():int

Computes the depth of the tree, starting from this node.

numChildren

public function get numChildren():int

The total number of children.

numSiblings

public function get numSiblings():int

The total number of siblings.

contains

public function contains(obj: *):Boolean

@inheritDoc

clear

public function clear():void

@inheritDoc

getIterator

public function getIterator():Iterator

@inheritDoc

getTreeIterator

public function getTreeIterator():TreeIterator

Creates a tree iterator pointing at this tree node.

Returns

A TreeIterator object. 

toArray

public function toArray():Array

@inheritDoc

toString

public function toString():String

Prints out a string representing the current object.

Returns

A string representing the current object. 

dump

public function dump():String

Prints out all elements (for debug/demo purposes).

Returns

A human-readable representation of the structure. 

A ‘java-style’ collection interface.
public var parent: TreeNode
The parent node being referenced.
public var children: DLinkedList
A list of child nodes being referenced.
public var data: *
The data being referened.
public function TreeNode(obj: * = null,
parent: TreeNode = null)
Creates a tree node.
public function get size():int
Counts the total number of tree nodes starting from the current tree node.
public function isRoot():Boolean
Checks if the tree node is a root node.
public function isLeaf():Boolean
Checks if the tree node is a leaf node.
public function hasChildren():Boolean
Checks if the tree node has child nodes.
public function hasSiblings():Boolean
Checks if the tree node has siblings.
public function isEmpty():Boolean
Checks is the tree node is empty (has no children).
public function get depth():int
Computes the depth of the tree, starting from this node.
public function get numChildren():int
The total number of children.
public function get numSiblings():int
The total number of siblings.
public function contains(obj: *):Boolean
@inheritDoc
public function clear():void
@inheritDoc
public function getIterator():Iterator
@inheritDoc
public function getTreeIterator():TreeIterator
Creates a tree iterator pointing at this tree node.
public function toArray():Array
@inheritDoc
public function toString():String
Prints out a string representing the current object.
public function dump():String
Prints out all elements (for debug/demo purposes).
Close