diff --git a/src/IntervalTree.php b/src/IntervalTree.php index a5b9fa8..43d6d0b 100644 --- a/src/IntervalTree.php +++ b/src/IntervalTree.php @@ -139,7 +139,12 @@ public function insert(array $key, $value = null) $value = $key; } - $insertNode = new Node($key, $value, $this->nilNode, $this->nilNode, null, Node::COLOR_RED); + $insertNode = new Node($key, $value); + $insertNode->left = $this->nilNode; + $insertNode->right = $this->nilNode; + $insertNode->parent = null; + $insertNode->color = Node::COLOR_RED; + $this->treeInsert($insertNode); $this->recalcMax($insertNode); return $insertNode; diff --git a/src/Node.php b/src/Node.php index 041cca7..e2fbafa 100644 --- a/src/Node.php +++ b/src/Node.php @@ -45,13 +45,8 @@ class Node public $max; - public function __construct($key = null, $value = null, $left = null, $right = null, $parent = null, $color = self::COLOR_BLACK) + public function __construct($key = null, $value = null) { - $this->left = $left; - $this->right = $right; - $this->parent = $parent; - $this->color = $color; - if (is_null($key)) { $this->item = new Item($key, $value); // key is supposed to be instance of Interval } elseif ($key && is_array($key) && count($key) === 2) {