/** * Check wether there should be changes in the downward tree structure. * * @return boolean */ protected function hasChange() { return !($this->bound1() == $this->node->getRight() || $this->bound1() == $this->node->getLeft()); }
/** * @param Node $node * @param array $array * @param Key $lo * @param Key $hi */ private function _range(Node $node, array &$array, Key $lo, Key $hi) { if (!$node->getLength()) { return; } $cmpLo = $node->getKey()->compare($lo); $cmpHi = $node->getKey()->compare($hi); if ($cmpLo > 0) { $this->_range($node->getLeft(), $array, $lo, $hi); } if ($cmpLo >= 0 && $cmpHi <= 0) { $array[] = $node; } if ($cmpHi < 0) { $this->_range($node->getRight(), $array, $lo, $hi); } }
private function balance(Node $node) : Node { if ($node->getRight()->isRed()) { return $this->rotateLeft($node); } return $node; }