Set is an 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.

Like all objects in PHP, Sets have reference-like semantics. When a caller passes a Set to a callee, the callee can modify the Set and the caller will see the changes. Sets do not have "copy-on-write" semantics.

Sets preserve insertion order of the elements. When iterating over a Set, the elements appear in the order they were inserted. Also, Sets do not automagically convert integer-like strings (ex. "123") into integers.

Sets only support int values and string values. If a value of a different type is used, an exception will be thrown.

In general, Sets do not support $c[$k] style syntax. Adding an element using $c[] = .. syntax is supported.

Set do not support iteration while elements are being added or removed. When an element is added or removed, all iterators that point to the Set shall be considered invalid.



More documentation and examples are in the [Set and ImmSet](</hack/arrays-and-collections/collections#set-and-immset>) guide.

Interface Synopsis

namespace HH;

final class Set implements \MutableSet<Tv> {...}

Public Methods