Ejemplo n.º 1
0
 public function __construct(AbstractBinaryTree $left = NULL, AbstractBinaryTree $right = NULL, $data)
 {
     parent::__construct($data);
     $this->left = $left;
     $this->right = $right;
     if ($this->left != NULL) {
         $this->directChildrenCount++;
     }
     if ($this->right != NULL) {
         $this->directChildrenCount++;
     }
 }
Ejemplo n.º 2
0
 public function __construct(array $children, $data)
 {
     parent::__construct($data);
     // simulating array object type hinting :((
     if (count($children)) {
         foreach ($children as $v) {
             if ($v instanceof NaryTree) {
                 $this->directChildrenCount++;
             } else {
                 throw new IllegalArgumentException();
             }
         }
     } else {
         $this->directChildrenCount = 0;
     }
     $this->children = $children;
 }