Exemple #1
0
 public function test_that_it_allows_color_replacement()
 {
     $monday = WeekDay::MONDAY();
     $node = new RedBlackNode($monday, 'Monday', 1, RedBlackNode::RED);
     $node->setColor(RedBlackNode::BLACK);
     $this->assertSame(RedBlackNode::BLACK, $node->color());
 }
Exemple #2
0
 /**
  * Flips the colors of a node and its two children
  *
  * Used to maintain symmetric order and perfect black balance when a black
  * node has two red children.
  *
  * @param RedBlackNode $node The node
  *
  * @return void
  */
 protected function flipColors(RedBlackNode $node)
 {
     $node->setColor(!$node->color());
     $node->left()->setColor(!$node->left()->color());
     $node->right()->setColor(!$node->right()->color());
 }