Exemple #1
0
 /**
  * Constructs a GeneralTree with the specified key.
  *
  * @param object IObject $key The desired key.
  */
 public function __construct(IObject $key)
 {
     parent::__construct();
     $this->key = $key;
     $this->degree = 0;
     $this->list = new LinkedList();
 }
Exemple #2
0
 /**
  * Construct an NaryTree with the specified degree
  * and the specified key.
  *
  * @param integer $degree The desired degree.
  * @param mixed $key The desired key.
  */
 public function __construct($degree, $key = NULL)
 {
     parent::__construct();
     $this->key = $key;
     $this->degree = $degree;
     if ($this->key === NULL) {
         $this->subtree = NULL;
     } else {
         $this->subtree = new BasicArray($degree);
         for ($i = 0; $i < $degree; ++$i) {
             $this->subtree[$i] = new NaryTree($degree);
         }
     }
 }
Exemple #3
0
 /**
  * Constructs a BinaryTree with the specified key,
  * and the specified left and right subtree.
  *
  * @param object IObject $key The key in this node.
  * @param mixed $left The left subtree of this node.
  * @param mixed $right The left subtree of this node.
  */
 public function __construct($key = NULL, $left = NULL, $right = NULL)
 {
     parent::__construct();
     $this->key = $key;
     if ($key === NULL) {
         $this->left = NULL;
         $this->right = NULL;
     } elseif ($left === NULL) {
         $this->left = new BinaryTree();
         $this->right = new BinaryTree();
     } else {
         $this->left = $left;
         $this->right = $right;
     }
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
 }