hphp/hack/manual/apis/Classes/HH/ImmVector/index.md
:::info[Note] This is a point-in-time snapshot of the API documentation from January 2026. Going forward, we will not be maintaining a public copy of these references, and recommend users to refer to the built-in signature helpers available in the Hack LSP instead for complete and up-to-date information. :::
ImmVector is an immutable Vector
HHVM provides a native implementation for this class. The PHP class definition below is not actually used at run time; it is simply provided for the typechecker and for developer reference.
An ImmVector cannot be mutated. No elements can be added to it or removed
from it, nor can elements be overwritten using assignment (i.e. $c[$k] = $v
is not allowed).
$v = Vector {1, 2, 3};
$fv = $v->toImmVector();
construct it with a Traversable:
$a = vec[1, 2, 3];
$fv = new ImmVector($a);
or use the literal syntax:
$fv = ImmVector {1, 2, 3};
namespace HH;
final class ImmVector implements \ConstVector<Tv> {...}
::fromItems(?Traversable<Tv> $iterable): ImmVector<Tv>ImmVector from the given Traversable, or an empty
ImmVector if null is passed::fromKeysOf<Tk as arraykey>(?KeyedContainer<Tk, mixed> $container): ImmVector<Tk>ImmVector from the keys of the specified container->__construct(?Traversable<Tv> $iterable = NULL): voidImmVector from the given Traversable, or an empty
ImmVector if null is passed->__toString(): stringstring version of the current ImmVector, which is
"ImmVector"->at(int $key): TvImmVector->concat<Tu super Tv>(Traversable<Tu> $traversable): ImmVector<Tu>ImmVector that is the concatenation of the values of the
current ImmVector and the values of the provided Traversable->containsKey(mixed $key): boolImmVector->count(): intImmVector->filter((function(Tv): bool) $callback): ImmVector<Tv>ImmVector containing the values of the current ImmVector that
meet a supplied condition->filterWithKey((function(int, Tv): bool) $callback): ImmVector<Tv>ImmVector containing the values of the current ImmVector
that meet a supplied condition applied to its keys and values->firstKey(): ?intImmVector->firstValue(): ?TvImmVector->get(int $key): ?TvImmVector->getIterator(): KeyedIterator<int, Tv>ImmVector->immutable(): ImmVector<Tv>ImmVector->isEmpty(): boolImmVector is empty->items(): Iterable<Tv>Iterable view of the current ImmVector->keys(): ImmVector<int>ImmVector containing the keys, as values, of the current
ImmVector->lastKey(): ?intImmVector->lastValue(): ?TvImmVector->lazy(): KeyedIterable<int, Tv>ImmVector->linearSearch(mixed $search_value): int->map<Tu>((function(Tv): Tu) $callback): ImmVector<Tu>ImmVector containing the results of applying an operation to
each value in the current ImmVector->mapWithKey<Tu>((function(int, Tv): Tu) $callback): ImmVector<Tu>ImmVector containing the results of applying an operation to
each key/value pair in the current ImmVector->skip(int $n): ImmVector<Tv>ImmVector containing the values after the $n-th element of
the current ImmVector->skipWhile((function(Tv): bool) $fn): ImmVector<Tv>ImmVector containing the values of the current ImmVector
starting after and including the first value that produces false when
passed to the specified callback->slice(int $start, int $len): ImmVector<Tv>ImmVector starting from a given key up
to, but not including, the element at the provided length from the
starting key->take(int $n): ImmVector<Tv>ImmVector containing the first $n values of the current
ImmVector->takeWhile((function(Tv): bool) $callback): ImmVector<Tv>ImmVector containing the values of the current ImmVector up
to but not including the first value that produces false when passed to
the specified callback->toDArray(): darray<int, Tv>->toImmMap(): ImmMap<int, Tv>ImmMap) based on the elements of
the current ImmVector->toImmSet(): ImmSet<Tv>ImmSet) with the values of the current
ImmVector->toImmVector(): ImmVector<Tv>ImmVector->toKeysArray(): varray<Tv>array whose values are the keys from the current ImmVector->toMap(): Map->toSet(): Set->toVArray(): varray<Tv>->toValuesArray(): varray<Tv>array containing the values from the current ImmVector->toVector(): Vector->values(): ImmVector<Tv>ImmVector containing the values of the current ImmVector;
that is, a copy of the current ImmVector->zip<Tu>(Traversable<Tu> $traversable): ImmVector<Pair<Tv, Tu>>ImmVector where each element is a Pair that combines the
element of the current ImmVector and the provided Traversable