/** * {@inheritdoc} */ public function add($item) { assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('add', $item)); $this->tree->set($item, true); }
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); }
/** * {@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); }