diff --git a/src/Item.php b/src/Item.php new file mode 100644 index 0000000..aa4c1f8 --- /dev/null +++ b/src/Item.php @@ -0,0 +1,26 @@ +key = $key; + $this->value = $value; + } + + function getKey(): Interval + { + return $this->key; + } + + + function getValue() + { + return $this->value; + } +} diff --git a/src/Node.php b/src/Node.php index 5025393..041cca7 100644 --- a/src/Node.php +++ b/src/Node.php @@ -1,4 +1,5 @@ left = $left; $this->right = $right; $this->parent = $parent; $this->color = $color; - $this->item = (object) compact('key', 'value'); // key is supposed to be instance of Interval - - /* If not, this should by an array of two numbers */ - if ($key && is_array($key) && count($key) === 2) { - $this->item->key = new Interval(min($key), max($key)); + 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) { + $item = new Item(new Interval(min($key), max($key)), $value); + $this->item = $item; } $this->max = $this->item->key ? clone $this->item->key : null; @@ -88,7 +88,7 @@ public function equalTo($otherNode) $valueEqual = true; if ($this->item->value && $otherNode->item->value) { $valueEqual = $this->item->value ? $this->item->value->equalTo($otherNode->item->value) : - $this->item->value == $otherNode->item->value; + $this->item->value == $otherNode->item->value; } return $this->item->key->equalTo($otherNode->item->key) && $valueEqual; }