HH\ImmVector
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};
Guides
Interface Synopsis
namespace HH;
final class ImmVector implements \ConstVector<Tv> {...}
Public Methods
::fromItems(?Traversable<Tv> $iterable): ImmVector<Tv>
Creates anImmVectorfrom the givenTraversable, or an emptyImmVectorifnullis passed::fromKeysOf<Tk as arraykey>(?KeyedContainer<Tk, mixed> $container): ImmVector<Tk>
Creates anImmVectorfrom the keys of the specified container->__construct(?Traversable<Tv> $iterable = NULL): void
Creates anImmVectorfrom the givenTraversable, or an emptyImmVectorifnullis passed->__toString(): string
Returns thestringversion of the currentImmVector, which is"ImmVector"->at(int $key): Tv
Returns the value at the specified key in the currentImmVector->concat<Tu super Tv>(Traversable<Tu> $traversable): ImmVector<Tu>
Returns anImmVectorthat is the concatenation of the values of the currentImmVectorand the values of the providedTraversable->containsKey(mixed $key): bool
Determines if the specified key is in the currentImmVector->count(): int
Returns the number of elements in the currentImmVector->filter((function(Tv): bool) $callback): ImmVector<Tv>
Returns aImmVectorcontaining the values of the currentImmVectorthat meet a supplied condition->filterWithKey((function(int, Tv): bool) $callback): ImmVector<Tv>
Returns anImmVectorcontaining the values of the currentImmVectorthat meet a supplied condition applied to its keys and values->firstKey(): ?int
Returns the first key in the currentImmVector->firstValue(): ?Tv
Returns the first value in the currentImmVector->get(int $key): ?Tv
Returns the value at the specified key in the currentImmVector->getIterator(): KeyedIterator<int, Tv>
Returns an iterator that points to beginning of the currentImmVector->immutable(): ImmVector<Tv>
Returns the currentImmVector->isEmpty(): bool
Checks if the currentImmVectoris empty->items(): Iterable<Tv>
Returns anIterableview of the currentImmVector->keys(): ImmVector<int>
Returns anImmVectorcontaining the keys, as values, of the currentImmVector->lastKey(): ?int
Returns the last key in the currentImmVector->lastValue(): ?Tv
Returns the last value in the currentImmVector->lazy(): KeyedIterable<int, Tv>
Returns a lazy, access-elements-only-when-needed view of the currentImmVector->linearSearch(mixed $search_value): int
Returns the index of the first element that matches the search value->map<Tu>((function(Tv): Tu) $callback): ImmVector<Tu>
Returns anImmVectorcontaining the results of applying an operation to each value in the currentImmVector->mapWithKey<Tu>((function(int, Tv): Tu) $callback): ImmVector<Tu>
Returns anImmVectorcontaining the results of applying an operation to each key/value pair in the currentImmVector->skip(int $n): ImmVector<Tv>
Returns anImmVectorcontaining the values after the$n-th element of the currentImmVector->skipWhile((function(Tv): bool) $fn): ImmVector<Tv>
Returns anImmVectorcontaining the values of the currentImmVectorstarting after and including the first value that producesfalsewhen passed to the specified callback->slice(int $start, int $len): ImmVector<Tv>
Returns a subset of the currentImmVectorstarting from a given key up to, but not including, the element at the provided length from the starting key->take(int $n): ImmVector<Tv>
Returns anImmVectorcontaining the first$nvalues of the currentImmVector->takeWhile((function(Tv): bool) $callback): ImmVector<Tv>
Returns anImmVectorcontaining the values of the currentImmVectorup to but not including the first value that producesfalsewhen passed to the specified callback->toDArray(): darray<int, Tv>->toImmMap(): ImmMap<int, Tv>
Returns an immutable integer-keyed Map (ImmMap) based on the elements of the currentImmVector->toImmSet(): ImmSet<Tv>
Returns an immutable Set (ImmSet) with the values of the currentImmVector->toImmVector(): ImmVector<Tv>
Returns the currentImmVector->toKeysArray(): varray<Tv>
Returns anarraywhose values are the keys from the currentImmVector->toMap(): Map
Returns a Map built from the keys and values of this ImmVector->toSet(): Set
Returns a Set built from the values of this ImmVector->toVArray(): varray<Tv>
Returns a varray built from the values from this ImmVector->toValuesArray(): varray<Tv>
Returns anarraycontaining the values from the currentImmVector->toVector(): Vector
Returns a Vector built from the values of this ImmVector->values(): ImmVector<Tv>
Returns a newImmVectorcontaining the values of the currentImmVector; that is, a copy of the currentImmVector->zip<Tu>(Traversable<Tu> $traversable): ImmVector<Pair<Tv, Tu>>
Returns anImmVectorwhere each element is aPairthat combines the element of the currentImmVectorand the providedTraversable