コード例 #1
0
ファイル: Move.php プロジェクト: 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());
 }
コード例 #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);
     }
 }
コード例 #3
0
 private function flipColors(Node $node)
 {
     $node->setColor(Node::RED);
     $node->getLeft()->setColor(Node::BLACK);
     $node->getRight()->setColor(Node::BLACK);
 }