Hoa central
Public Member Functions | List of all members
Hoa\Tree\Tree Class Reference
Inheritance diagram for Hoa\Tree\Tree:

Public Member Functions

 insert (Generic $child)
 
 delete ($nodeId)
 
 isLeaf ()
 
 isNode ()
 
- Public Member Functions inherited from Hoa\Tree\Generic
 __construct ($value=null)
 
 setValue ($value)
 
 getValue ()
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 
 seek ($position)
 
 count ()
 
 getChild ($nodeId)
 
 getChilds ()
 
 childExists ($nodeId)
 
 insert (Generic $child)
 
 delete ($i)
 
 isLeaf ()
 
 isNode ()
 
 accept (Visitor\Visit $visitor, &$handle=null, $eldnah=null)
 
- Public Member Functions inherited from Hoa\Visitor\Element
 accept (Visit $visitor, &$handle=null, $eldnah=null)
 

Additional Inherited Members

- Protected Attributes inherited from Hoa\Tree\Generic
 $_value = null
 
 $_childs = []
 

Detailed Description

Class .

Manipule a tree.

Definition at line 49 of file Tree.php.

Member Function Documentation

Hoa\Tree\Tree::delete (   $nodeId)

Delete a child.

Parameters
mixed$nodeIdNode ID.
Returns
Exceptions

Definition at line 81 of file Tree.php.

82  {
83  unset($this->_childs[$nodeId]);
84 
85  return $this;
86  }
Hoa\Tree\Tree::insert ( Generic  $child)

Insert a child. Fill the child list from left to right.

Parameters
\Hoa\Tree$childChild to insert.
Returns
Exceptions

Definition at line 59 of file Tree.php.

60  {
61  if (!($child instanceof self)) {
62  throw new Exception(
63  'Child must be an instance of \Hoa\Tree; given %s.',
64  0,
65  get_class($child)
66  );
67  }
68 
69  $this->_childs[$child->getValue()->getId()] = $child;
70 
71  return $this;
72  }

Here is the call graph for this function:

Hoa\Tree\Tree::isLeaf ( )

Check if the node is a leaf.

Returns
bool

Definition at line 93 of file Tree.php.

94  {
95  return empty($this->_childs);
96  }
Hoa\Tree\Tree::isNode ( )

Check if the node is a node (i.e. not a leaf).

Returns
bool

Definition at line 103 of file Tree.php.

104  {
105  return !empty($this->_childs);
106  }

The documentation for this class was generated from the following file: