/** * {@inheritdoc} */ public function enqueue($item) { assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('enqueue', $item)); $this->list->push($item); }
/** * {@inheritdoc} */ public function add($item) { assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('add', $item)); $this->tree->set($item, true); }
/** * {@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)); $hash = Hasher::hash($key); if (!isset($this->buckets[$hash])) { $this->buckets[$hash] = new TableBucketChain(); } if ($this->buckets[$hash]->set($key, $value)) { $this->count++; } }
/** * {@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); }
/** * {@inheritdoc} */ public function push($item) { assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('push', $item)); $index = $this->count++; $this->items[$index] = $item; }
/** * @dataProvider invalidTypeProvider */ public function test_that_is_type_returns_false_for_invalid_value($value, $type) { $this->assertFalse(Validate::isType($value, $type)); }
/** * {@inheritdoc} */ public function add($item) { assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('add', $item)); $hash = Hasher::hash($item); if (!isset($this->buckets[$hash])) { $this->buckets[$hash] = new SetBucketChain(); } if ($this->buckets[$hash]->add($item)) { $this->count++; } }
/** * {@inheritdoc} */ public function set(int $index, $item) { assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('set', $item)); $count = count($this->items); if ($index < -$count || $index > $count - 1) { $message = sprintf('Index (%d) out of range[%d, %d]', $index, -$count, $count - 1); throw new IndexException($message); } if ($index < 0) { $index += $count; } $this->items[$index] = $item; }
/** * {@inheritdoc} */ public function addLast($item) { assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('addLast', $item)); $this->list->push($item); }
/** * {@inheritdoc} */ public function enqueue($item) { assert(Validate::isType($item, $this->itemType()), $this->itemTypeError('enqueue', $item)); if ($this->count === $this->cap) { $this->reindex($this->cap * 2); } $index = $this->end++; $this->items[$index] = $item; if ($this->end === $this->cap) { $this->end = 0; } $this->count++; }