Class TreeInterface

Description

The interface for the Tree data structure used by the Hierarchy.

  • version: $Id: Tree.interface.php,v 1.7 2007/09/04 20:25:42 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

Located in /harmoni/core/oki2/hierarchy/tree/Tree.interface.php (line 13)


	
			
Direct descendents
Class Description
Tree The Tree data structure used by the Hierarchy.
Method Summary
boolean addNode (ref $node, optional $parent)
void deleteNode (object node $node)
ref getAllNodes ()
array getAncestors (ref $node)
ref getNode (string $id)
integer getSize ()
array getSubtree (ref $node)
boolean nodeExists (string $id)
ref traverse (optional $node)
Methods
addNode (line 25)

Adds the specified node to the hierarchy and makes it a child of the specified parent. If the parent is not specified, then it makes the node a root.

  • return:
    1. true
    on success;
    1. false
    , otherwise.
  • access: public
boolean addNode (ref $node, optional $parent)
  • ref $node: object The node to add.
  • optional $parent: ref object parent The node that will become the parent of the added node.

Redefined in descendants as:
  • Tree::addNode() : Adds the specified node to the tree and makes it a child of the specified parent. If the parent is not specified, then it makes the node a root. Always use this method instead of the addChild() method of the individual tree nodes.
deleteNode (line 79)

Delete the node from the tree. This can only be done if the node has no parents and no children.

  • access: public
void deleteNode (object node $node)
  • object node $node: The node to delete.

Redefined in descendants as:
  • Tree::deleteNode() : Delete the node from the tree. This can only be done if the node has no parents and no children.
getAllNodes (line 113)

Simply returns all nodes of this hierarchy in an array in no particular order.

  • return: array An array of all nodes.
  • access: public
ref getAllNodes ()
getAncestors (line 50)

Returns all the ancestors of the given node.

  • return: An array of all the ancestors of the given node. Each array key corresponds to the hierarchy level of the ancestor. Each element stores the system id of the ancestor.
  • access: public
array getAncestors (ref $node)
  • ref $node: object node The node whose ancestors are to be found.
getNode (line 91)

Returns the node with the specified id. If it does not exist, return

  1. null
.

  • return: object The requested node.
    1. Null
    , if the node is not in the tree.
  • access: public
ref getNode (string $id)
  • string $id: id The id of the requested node.

Redefined in descendants as:
  • Tree::getNode() : Returns the node with the specified id. If it does not exist, return
    1. null
    .
getSize (line 36)

Returns the size (number of nodes) in this hierarchy.

  • return: The size (number of nodes) in this hierarchy.
  • access: public
integer getSize ()

Redefined in descendants as:
getSubtree (line 67)

Returns the subtree rooted at the specified node (excluding the root).

  • return: An array of all the nodes in the subtree rooted at the specified node. Each array key corresponds to a certain level in the hierarchy. For example, the first level (with array key = 0) will contain the root's children. The second level will have the root's grandchildren and so forth. The array does not consist of the actual node objects; instead, it only stores their system ids.
  • access: public
array getSubtree (ref $node)
  • ref $node: object node The node whose subtree is to be found.
nodeExists (line 102)

Returns

  1. true
if the node with the specified id (string) exists.

  • return:
    1. true
    if the node with the specified id is in the tree; else
    1. false
    .
  • access: public
boolean nodeExists (string $id)
  • string $id: id The id of the node.

Redefined in descendants as:
traverse (line 127)

Traverses the hierarchy and returns all the nodes in an array. The traversal is a pre-order traversal starting from the specified node.

  • return: array An array of all nodes in the hierarchy visited in a pre-order manner.
  • access: public
ref traverse (optional $node)
  • optional $node: ref object node An optional node to start traversal from.

Redefined in descendants as:
  • Tree::traverse() : Traverses the tree and returns all the nodes in an array. The traversal is a depth-first pre-order traversal starting from the specified node.

Documentation generated on Wed, 19 Sep 2007 10:27:33 -0400 by phpDocumentor 1.3.0RC3