hphp/hack/manual/apis/Classes/HH/ImmSet/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. :::
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};
namespace HH;
final class ImmSet implements \ConstSet<Tv> {...}
::fromArrays(...$argv): ImmSet<Tv>ImmSet containing all the values from the specified
array(s)::fromItems(?Traversable<Tv> $iterable): ImmSet<Tv>ImmSet from the given Traversable, or an empty ImmSet if
null is passed::fromKeysOf<Tk as arraykey>(?KeyedContainer<Tk, mixed> $container): ImmSet<Tk>ImmSet from the keys of the specified container->__construct(?Traversable<Tv> $iterable = NULL): voidImmSet from the given Traversable, or an empty ImmSet if
null is passed->__toString(): stringstring version of this ImmSet, which is "ImmSet"->concat<Tu super Tv>(Traversable<Tu> $traversable): ImmVector<Tu>ImmVector that is the concatenation of the values of the
current ImmSet and the values of the provided Traversable->contains(arraykey $val): boolImmSet->count(): intImmSet->filter((function(Tv): bool) $callback): ImmSet<Tv>ImmSet containing the values of the current ImmSet that
meet a supplied condition applied to each value->filterWithKey((function(arraykey, Tv): bool) $callback): ImmSet<Tv>ImmSet containing the values of the current ImmSet that
meet a supplied condition applied to its "keys" and values->firstKey(): ?arraykeyImmSet->firstValue(): ?TvImmSet->getIterator(): KeyedIterator<arraykey, Tv>ImmSet->immutable(): ImmSet<Tv>ImmSet) of the current ImmSet->isEmpty(): boolImmSet is empty->items(): Iterable<Tv>ImmSet->keys(): ImmVector<arraykey>ImmVector containing the values of this ImmSet->lastKey(): ?arraykeyImmSet->lastValue(): ?TvImmSet->lazy(): KeyedIterable<arraykey, Tv>ImmSet->map<Tu as arraykey>((function(Tv): Tu) $callback): ImmSet<Tu>ImmSet containing the values after an operation has been
applied to each value in the current ImmSet->mapWithKey<Tu as arraykey>((function(arraykey, Tv): Tu) $callback): ImmSet<Tu>ImmSet containing the values after an operation has been
applied to each "key" and value in the current ImmSet->skip(int $n): ImmSet<Tv>ImmSet containing the values after the n-th element of the
current ImmSet->skipWhile((function(Tv): bool) $fn): ImmSet<Tv>ImmSet containing the values of the current ImmSet starting
after and including the first value that produces true when passed to
the specified callback->slice(int $start, int $len): ImmSet<Tv>ImmSet 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>ImmSet containing the first n values of the current ImmSet->takeWhile((function(Tv): bool) $callback): ImmSet<Tv>ImmSet containing the values of the current ImmSet up to
but not including the first value that produces false when passed to the
specified callback->toDArray(): darray<Tv, Tv>->toImmMap(): ImmMap<arraykey, Tv>ImmMap) based on the values of the current
ImmSet->toImmSet(): ImmSet<Tv>ImmSet) of the current ImmSet->toImmVector(): ImmVector<Tv>ImmVector) with the values of the current
ImmSet->toKeysArray(): varray<Tv>array containing the values from the current ImmSet->toMap(): object->toSet(): object->toVArray(): varray<Tv>->toValuesArray(): varray<Tv>array containing the values from the current ImmSet->toVector(): object->values(): ImmVector<Tv>ImmVector containing the values of the current ImmSet->zip<Tu>(Traversable<Tu> $traversable): ImmSet<nothing>ImmSet or the Traversable is
empty