From a546475e59cb51d836ce9e0eddb7ddd527895dd3 Mon Sep 17 00:00:00 2001 From: dan1 Date: Sat, 14 Nov 2020 23:51:17 +0500 Subject: [PATCH] remove parameters hell for node constructor --- src/IntervalTree.php | 7 ++++++- src/Node.php | 7 +------ 2 files changed, 7 insertions(+), 7 deletions(-) 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) {