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 anImmSetcontaining all the values from the specifiedarray(s)::fromItems(?Traversable<Tv> $iterable): ImmSet<Tv>
Creates anImmSetfrom the givenTraversable, or an emptyImmSetifnullis passed::fromKeysOf<Tk as arraykey>(?KeyedContainer<Tk, mixed> $container): ImmSet<Tk>
Creates anImmSetfrom the keys of the specified container->__construct(?Traversable<Tv> $iterable = NULL): void
Creates anImmSetfrom the givenTraversable, or an emptyImmSetifnullis passed->__toString(): string
Returns thestringversion of thisImmSet, which is"ImmSet"->concat<Tu super Tv>(Traversable<Tu> $traversable): ImmVector<Tu>
Returns anImmVectorthat is the concatenation of the values of the currentImmSetand 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 anImmSetcontaining the values of the currentImmSetthat meet a supplied condition applied to each value->filterWithKey((function(arraykey, Tv): bool) $callback): ImmSet<Tv>
Returns anImmSetcontaining the values of the currentImmSetthat 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 currentImmSetis empty->items(): Iterable<Tv>
Returns an Iterable view of the currentImmSet->keys(): ImmVector<arraykey>
Returns anImmVectorcontaining 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 anImmSetcontaining 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 anImmSetcontaining the values after an operation has been applied to each "key" and value in the currentImmSet->skip(int $n): ImmSet<Tv>
Returns anImmSetcontaining the values after then-th element of the currentImmSet->skipWhile((function(Tv): bool) $fn): ImmSet<Tv>
Returns anImmSetcontaining the values of the currentImmSetstarting after and including the first value that producestruewhen passed to the specified callback->slice(int $start, int $len): ImmSet<Tv>
Returns a subset of the currentImmSetstarting 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 anImmSetcontaining the first n values of the currentImmSet->takeWhile((function(Tv): bool) $callback): ImmSet<Tv>
Returns anImmSetcontaining the values of the currentImmSetup to but not including the first value that producesfalsewhen 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 anarraycontaining 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 anarraycontaining the values from the currentImmSet->toVector(): object
Returns a Vector built from the values of this ImmSet->values(): ImmVector<Tv>
Returns anImmVectorcontaining the values of the currentImmSet->zip<Tu>(Traversable<Tu> $traversable): ImmSet<nothing>
Throws an exception unless the currentImmSetor theTraversableis empty