Skip to content

Commit

Permalink
remove parameters hell for node constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-on committed Nov 14, 2020
1 parent 2a40116 commit a546475
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/IntervalTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 1 addition & 6 deletions src/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a546475

Please sign in to comment.