Ejemplo n.º 1
0
Archivo: Move.php Proyecto: sonars/tree
 /**
  * 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());
 }
Ejemplo n.º 2
0
 /**
  * @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);
     }
 }
Ejemplo n.º 3
0
 private function balance(Node $node) : Node
 {
     if ($node->getRight()->isRed()) {
         return $this->rotateLeft($node);
     }
     return $node;
 }