nodes = array(); } /** * Adds given node to the Tree * @method addNode * @param mixed id * @param mixed node * @returns true if successful, false otherwise */ function addNode($id, $node) { $success = true; if($id == -1) $this->nodes[] = $node; else if(isset($this->nodes[$id])) $success = false; else $this->nodes[$id] = $node; return $success; } /** * Removes all nodes * @method removeAllNodes * @returns none */ function removeAllNodes () { $this->nodes = array(); } /** * Removes specified node from the Tree * @method removeNode * @param mixed id * @returns true if successful, false otherwise */ function removeNode($id) { $success = false; if(isset($this->nodes[$id])) { unset($this->nodes[$id]); $success = true; } return $success; } } ?>