예제 #1
0
파일: SortedSet.php 프로젝트: novuso/system
 /**
  * {@inheritdoc}
  */
 public function add($item)
 {
     assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('add', $item));
     $this->tree->set($item, true);
 }
예제 #2
0
 public function test_that_clone_includes_linked_nodes()
 {
     $tree = new RedBlackSearchTree(new ComparableComparator());
     foreach ($this->getWeekDays() as $value => $key) {
         $tree->set($key, $value);
     }
     $copy = clone $tree;
     while (!$tree->isEmpty()) {
         $tree->removeMin();
     }
     $this->assertCount(7, $copy);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     assert(Validate::isType($key, $this->keyType()), $this->keyTypeError('set', $key));
     assert(Validate::isType($value, $this->valueType()), $this->valueTypeError('set', $value));
     $this->tree->set($key, $value);
 }