/** * @param integer $index * @param mixed $value * @return Vector * @throws OutOfBoundsException */ public function assoc($index, $value) { if ($index === $this->count) { return $this->append($value); } if ($index > $this->count) { throw new OutOfBoundsException('Cannot assoc pased the end of the vector'); } $vector = new Vector(); $vector->trie = $this->trie->put($index, $value); $vector->count = $this->count; return $vector; }