Skip to content

Commit a546475

Browse files
committed
remove parameters hell for node constructor
1 parent 2a40116 commit a546475

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/IntervalTree.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ public function insert(array $key, $value = null)
139139
$value = $key;
140140
}
141141

142-
$insertNode = new Node($key, $value, $this->nilNode, $this->nilNode, null, Node::COLOR_RED);
142+
$insertNode = new Node($key, $value);
143+
$insertNode->left = $this->nilNode;
144+
$insertNode->right = $this->nilNode;
145+
$insertNode->parent = null;
146+
$insertNode->color = Node::COLOR_RED;
147+
143148
$this->treeInsert($insertNode);
144149
$this->recalcMax($insertNode);
145150
return $insertNode;

src/Node.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,8 @@ class Node
4545

4646
public $max;
4747

48-
public function __construct($key = null, $value = null, $left = null, $right = null, $parent = null, $color = self::COLOR_BLACK)
48+
public function __construct($key = null, $value = null)
4949
{
50-
$this->left = $left;
51-
$this->right = $right;
52-
$this->parent = $parent;
53-
$this->color = $color;
54-
5550
if (is_null($key)) {
5651
$this->item = new Item($key, $value); // key is supposed to be instance of Interval
5752
} elseif ($key && is_array($key) && count($key) === 2) {

0 commit comments

Comments
 (0)