HH\ImmSet
ImmSet
is an immutable, ordered set-style collection
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 ImmSet
cannot be mutated. No elements can be added or removed from it,
nor can elements be overwritten using assignment (i.e. $s[$k] = $v
is
not allowed).
Construct it with a Traversable
:
$a = vec[1, 2];
$s = new ImmSet($a);
or use the literal syntax:
$s = ImmSet {1, 2};
Guides
Interface Synopsis
namespace HH;
final class ImmSet implements \ConstSet<Tv> {...}
Public Methods
::fromArrays(...$argv): ImmSet<Tv>
Returns anImmSet
containing all the values from the specifiedarray
(s)::fromItems(?Traversable<Tv> $iterable): ImmSet<Tv>
Creates anImmSet
from the givenTraversable
, or an emptyImmSet
ifnull
is passed::fromKeysOf<Tk as arraykey>(?KeyedContainer<Tk, mixed> $container): ImmSet<Tk>
Creates anImmSet
from the keys of the specified container->__construct(?Traversable<Tv> $iterable = NULL): void
Creates anImmSet
from the givenTraversable
, or an emptyImmSet
ifnull
is passed->__toString(): string
Returns thestring
version of thisImmSet
, which is"ImmSet"
->concat<Tu super Tv>(Traversable<Tu> $traversable): ImmVector<Tu>
Returns anImmVector
that is the concatenation of the values of the currentImmSet
and the values of the providedTraversable
->contains(arraykey $val): bool
Determines if the specified value is in the currentImmSet
->count(): int
Provides the number of elements in the currentImmSet
->filter((function(Tv): bool) $callback): ImmSet<Tv>
Returns anImmSet
containing the values of the currentImmSet
that meet a supplied condition applied to each value->filterWithKey((function(arraykey, Tv): bool) $callback): ImmSet<Tv>
Returns anImmSet
containing the values of the currentImmSet
that meet a supplied condition applied to its "keys" and values->firstKey(): ?arraykey
Returns the first "key" in the currentImmSet
->firstValue(): ?Tv
Returns the first value in the currentImmSet
->getIterator(): KeyedIterator<arraykey, Tv>
Returns an iterator that points to beginning of the currentImmSet
->immutable(): ImmSet<Tv>
Returns an immutable copy (ImmSet
) of the currentImmSet
->isEmpty(): bool
Checks if the currentImmSet
is empty->items(): Iterable<Tv>
Returns an Iterable view of the currentImmSet
->keys(): ImmVector<arraykey>
Returns anImmVector
containing the values of thisImmSet
->lastKey(): ?arraykey
Returns the last "key" in the currentImmSet
->lastValue(): ?Tv
Returns the last value in the currentImmSet
->lazy(): KeyedIterable<arraykey, Tv>
Returns a lazy, access elements only when needed view of the currentImmSet
->map<Tu as arraykey>((function(Tv): Tu) $callback): ImmSet<Tu>
Returns anImmSet
containing the values after an operation has been applied to each value in the currentImmSet
->mapWithKey<Tu as arraykey>((function(arraykey, Tv): Tu) $callback): ImmSet<Tu>
Returns anImmSet
containing the values after an operation has been applied to each "key" and value in the currentImmSet
->skip(int $n): ImmSet<Tv>
Returns anImmSet
containing the values after then
-th element of the currentImmSet
->skipWhile((function(Tv): bool) $fn): ImmSet<Tv>
Returns anImmSet
containing the values of the currentImmSet
starting after and including the first value that producestrue
when passed to the specified callback->slice(int $start, int $len): ImmSet<Tv>
Returns a subset of the currentImmSet
starting from a given key up to, but not including, the element at the provided length from the starting key->take(int $n): ImmSet<Tv>
Returns anImmSet
containing the first n values of the currentImmSet
->takeWhile((function(Tv): bool) $callback): ImmSet<Tv>
Returns anImmSet
containing the values of the currentImmSet
up to but not including the first value that producesfalse
when passed to the specified callback->toDArray(): darray<Tv, Tv>
Returns a darray built from the values from this ImmSet, darray[val1 => val1, val2 => val2, ...]->toImmMap(): ImmMap<arraykey, Tv>
Returns an immutable map (ImmMap
) based on the values of the currentImmSet
->toImmSet(): ImmSet<Tv>
Returns an immutable copy (ImmSet
) of the currentImmSet
->toImmVector(): ImmVector<Tv>
Returns an immutable vector (ImmVector
) with the values of the currentImmSet
->toKeysArray(): varray<Tv>
Returns anarray
containing the values from the currentImmSet
->toMap(): object
Returns a Map built from the keys and values of this ImmSet->toSet(): object
Returns a Set built from the values of this ImmSet->toVArray(): varray<Tv>
->toValuesArray(): varray<Tv>
Returns anarray
containing the values from the currentImmSet
->toVector(): object
Returns a Vector built from the values of this ImmSet->values(): ImmVector<Tv>
Returns anImmVector
containing the values of the currentImmSet
->zip<Tu>(Traversable<Tu> $traversable): ImmSet<nothing>
Throws an exception unless the currentImmSet
or theTraversable
is empty