MaybeMutable the collection builtins
[hiphop-php.git] / hphp / hack / hhi / collections / Set.hhi
blob572df914bd5bb232e6220b2285fb22238da439b4
1 <?hh // decl
2 /**
3  * Copyright (c) 2014, Facebook, Inc.
4  * All rights reserved.
5  *
6  * This source code is licensed under the MIT license found in the
7  * LICENSE file in the "hack" directory of this source tree.
8  *
9  */
11 /**
12  * This file provides type information for some of HHVM's builtin classes.
13  *
14  * YOU SHOULD NEVER INCLUDE THIS FILE ANYWHERE!!!
15  */
17 /**
18  * `Set` is an ordered set-style collection. HHVM provides a native
19  * implementation for this class. The PHP class definition below is not
20  * actually used at run time; it is simply provided for the typechecker and
21  * for developer reference.
22  *
23  * Like all objects in PHP, `Set`s have reference-like semantics. When a caller
24  * passes a `Set` to a callee, the callee can modify the `Set` and the caller
25  * will see the changes. `Set`s do not have "copy-on-write" semantics.
26  *
27  * `Set`s preserve insertion order of the elements. When iterating over a
28  * `Set`, the elements appear in the order they were inserted. Also, `Set`s do
29  * not automagically convert integer-like strings (ex. "123") into integers.
30  *
31  * `Set`s only support `int` values and `string` values. If a value of a
32  * different type is used, an exception will be thrown.
33  *
34  * In general, Sets do not support `$c[$k]` style syntax. Adding an element
35  * using `$c[] = ..` syntax is supported.
36  *
37  * `Set` do not support iteration while elements are being added or removed.
38  * When an element is added or removed, all iterators that point to the `Set`
39  * shall be considered invalid.
40  *
41  * `Set`s do not support taking elements by reference. If binding assignment
42  * (`=&`) is used when adding a new element to a `Set` (ex. `$c[] =& ...`), or
43  * if a `Set` is used with `foreach` by reference, an exception will be thrown.
44  *
45  * @guide /hack/collections/introduction
46  * @guide /hack/collections/classes
47  */
49 final class Set<Tv> implements MutableSet<Tv> {
50   /**
51    * Creates a `Set` from the given `Traversable`, or an empty `Set` if `null`
52    * is passed.
53    *
54    * @param $it - any `Traversable` object from which to create the `Set`
55    *              (e.g., `array`). If `null`, then an empty `Set` is created.
56    */
57   <<__Rx, __OnlyRxIfArgs>>
58   public function __construct(<<__MaybeMutable, __OnlyRxIfImpl(HH\Rx\Traversable::class)>> ?Traversable<Tv> $it);
60   /**
61    * Returns an `array` containing the values from the current `Set`.
62    *
63    * For the returned `array`, each key is the same as its associated value.
64    *
65    * @return - an `array` containing the values from the current `Set`, where
66    *           each key of the `array` are the same as each value.
67    */
68   <<__Rx, __MaybeMutable>>
69   /* HH_IGNORE_ERROR[2082] T30260145 */
70   public function toArray(): array<Tv, Tv>;
72   /**
73    * Returns an `array` containing the values from the current `Set`.
74    *
75    * `Set`s don't have keys. So this method just returns the values.
76    *
77    * This method is interchangeable with `toValuesArray()`.
78    *
79    * @return - an integer-indexed `array` containing the values from the
80    *           current `Set`.
81    */
82   <<__Rx, __MaybeMutable>>
83   public function toKeysArray(): varray<Tv>;
85   /**
86    * Returns an `array` containing the values from the current `Set`.
87    *
88    * This method is interchangeable with `toKeysArray()`.
89    *
90    * @return - an integer-indexed `array` containing the values from the
91    *           current `Set`.
92    */
93   <<__Rx, __MaybeMutable>>
94   public function toValuesArray(): varray<Tv>;
96   /**
97    * Returns a `Vector` of the current `Set` values.
98    *
99    * @return - a `Vector` (integer-indexed) that contains the values of the
100    *           current `Set`.
101    */
102   <<__Rx, __MutableReturn, __MaybeMutable>>
103   public function toVector(): Vector<Tv>;
105   /**
106    * Returns an immutable vector (`ImmVector`) with the values of the current
107    * `Set`.
108    *
109    * @return - an `ImmVector` (integer-indexed) with the values of the current
110    *           `Set`.
111    */
112   <<__Rx, __MaybeMutable>>
113   public function toImmVector(): ImmVector<Tv>;
115   /**
116    * Returns a `Map` based on the values of the current `Set`.
117    *
118    * Each key of the `Map` will be the same as its value.
119    *
120    * @return - a `Map` that that contains the values of the current `Set`, with
121    *           each key of the `Map` being the same as its value.
122    */
123   <<__Rx, __MutableReturn, __MaybeMutable>>
124   public function toMap(): Map<arraykey, Tv>;
126   /**
127    * Returns an immutable map (`ImmMap`) based on the values of the current
128    * `Set`.
129    *
130    * Each key of the `Map` will be the same as its value.
131    *
132    * @return - an `ImmMap` that that contains the values of the current `Set`,
133    *           with each key of the Map being the same as its value.
134    */
135   <<__Rx, __MaybeMutable>>
136   public function toImmMap(): ImmMap<arraykey, Tv>;
138   /**
139    * Returns a deep copy of the current `Set`.
140    *
141    * @return - a `Set` that is a deep copy of the current `Set`.
142    */
143   <<__Rx, __MutableReturn, __MaybeMutable>>
144   public function toSet(): Set<Tv>;
146   /**
147    * Returns an immutable (`ImmSet`), deep copy of the current `Set`.
148    *
149    * This method is interchangeable with `immutable()`.
150    *
151    * @return - an `ImmSet` that is a deep copy of the current `Set`.
152    */
153   <<__Rx, __MaybeMutable>>
154   public function toImmSet(): ImmSet<Tv>;
156   /**
157    * Returns an immutable (`ImmSet`), deep copy of the current `Set`.
158    *
159    * This method is interchangeable with `toImmSet()`.
160    *
161    * @return - an `ImmSet` that is a deep copy of the current `Set`.
162    */
163   <<__Rx, __MaybeMutable>>
164   public function immutable(): ImmSet<Tv>;
166   /**
167    * Returns a lazy, access elements only when needed view of the current
168    * `Set`.
169    *
170    * Normally, memory is allocated for all of the elements of the `Set`. With
171    * a lazy view, memory is allocated for an element only when needed or used
172    * in a calculation like in `map()` or `filter()`.
173    *
174    * @return - an `KeyedIterable` representing the lazy view into the current
175    *           `Set`, where the keys are the same as the values.
176    *
177    * @guide /hack/collections/examples
178    */
179   <<__Rx, __MutableReturn, __MaybeMutable>>
180   public function lazy(): HH\Rx\KeyedIterable<arraykey, Tv>;
182   /**
183    * Returns a `Vector` containing the values of the current `Set`.
184    *
185    * This method is interchangeable with `toVector()` and `keys()`.
186    *
187    * @return - a `Vector` (integer-indexed) containing the values of the
188    *           current `Set`.
189    */
190   <<__Rx, __MutableReturn, __MaybeMutable>>
191   public function values(): Vector<Tv>;
193   /**
194    * Returns a `Vector` containing the values of the current `Set`.
195    *
196    * `Set`s don't have keys, so this will return the values.
197    *
198    * This method is interchangeable with `toVector()` and `values()`.
199    *
200    * @return - a `Vector` (integer-indexed) containing the values of the
201    *           current `Set`.
202    */
203   <<__Rx, __MutableReturn, __MaybeMutable>>
204   public function keys(): Vector<arraykey>;
206   /**
207    * Returns a `Set` containing the values after an operation has been applied
208    * to each value in the current `Set`.
209    *
210    * Every value in the current `Set` is affected by a call to `map()`, unlike
211    * `filter()` where only values that meet a certain criteria are affected.
212    *
213    * @param $callback - The callback containing the operation to apply to the
214    *                    current `Set` values.
215    *
216    * @return - a `Set` containing the values after a user-specified operation
217    *           is applied.
218    *
219    * @guide /hack/collections/examples
220    */
221   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
222   public function map<Tu>(<<__OnlyRxIfRxFunc>>(function(Tv): Tu) $callback): Set<Tu>;
224   /**
225    * Returns a `Set` containing the values after an operation has been applied
226    * to each "key" and value in the current `Set`.
227    *
228    * Since `Set`s don't have keys, the callback uses the values as the keys
229    * as well.
230    *
231    * Every value in the current `Set` is affected by a call to `mapWithKey()`,
232    * unlike `filterWithKey()` where only values that meet a certain criteria are
233    * affected.
234    *
235    * @param $callback - The callback containing the operation to apply to the
236    *                    current `Set` keys and values.
237    *
238    * @return - a `Set` containing the values after a user-specified operation
239    *           on the current `Set`'s values is applied.
240    */
241   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
242   public function mapWithKey<Tu>(<<__OnlyRxIfRxFunc>>(function(arraykey, Tv): Tu) $callback): Set<Tu>;
244   /**
245    * Returns a `Set` containing the values of the current `Set` that meet
246    * a supplied condition applied to each value.
247    *
248    * Only values that meet a certain criteria are affected by a call to
249    * `filter()`, while all values are affected by a call to `map()`.
250    *
251    * @param $callback - The callback containing the condition to apply to the
252    *                    current `Set` values.
253    *
254    * @return - a `Set` containing the values after a user-specified condition
255    *           is applied.
256    *
257    * @guide /hack/collections/examples
258    */
259   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
260   public function filter(<<__OnlyRxIfRxFunc>>(function(Tv): bool) $callback): Set<Tv>;
262   /**
263    * Returns a `Set` containing the values of the current `Set` that meet
264    * a supplied condition applied to its "keys" and values.
265    *
266    * Since `Set`s don't have keys, the callback uses the values as the keys
267    * as well.
268    *
269    * Only values that meet a certain criteria are affected by a call to
270    * `filterWithKey()`, while all values are affected by a call to
271    * `mapWithKey()`.
272    *
273    * @param $callback - The callback containing the condition to apply to the
274    *                    current `Set` keys and values.
275    *
276    * @return - a `Set` containing the values after a user-specified condition
277    *           is applied to the values of the current `Set`.
278    *
279    */
280   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
281   public function filterWithKey(<<__OnlyRxIfRxFunc>>(function(arraykey, Tv): bool) $callback): Set<Tv>;
283   /**
284    * Alters the current `Set` so that it only contains the values that meet a
285    * supplied condition on each value.
286    *
287    * This method is like `filter()`, but mutates the current `Set` too in
288    * addition to returning the current `Set`.
289    *
290    * Future changes made to the current `Set` ARE reflected in the returned
291    * `Set`, and vice-versa.
292    *
293    * @param $callback - The callback containing the condition to apply to the
294    *                    current `Set` values.
295    *
296    * @return - Returns itself.
297    */
298   <<__Rx, __Mutable, __OnlyRxIfArgs, __ReturnsVoidToRx>>
299   public function retain(<<__OnlyRxIfRxFunc>>(function(Tv): bool) $callback): Set<Tv>;
301   /**
302    * Alters the current `Set` so that it only contains the values that meet a
303    * supplied condition on its "keys" and values.
304    *
305    * `Set`s don't have keys, so the `Set` values are used as the key in the
306    * callback.
307    *
308    * This method is like `filterWithKey()`, but mutates the current `Set` too
309    * in addition to returning the current `Set`.
310    *
311    * Future changes made to the current `Set` ARE reflected in the returned
312    * `Set`, and vice-versa.
313    *
314    * @param $callback - The callback containing the condition to apply to the
315    *                    current `Set` values.
316    *
317    * @return - Returns itself.
318    */
319   <<__Rx, __Mutable, __OnlyRxIfArgs, __ReturnsVoidToRx>>
320   public function retainWithKey(<<__OnlyRxIfRxFunc>>(function(arraykey, Tv): bool) $callback): Set<Tv>;
322   /**
323    * Throws an exception unless the current `Set` or the `Traversable` is
324    * empty.
325    *
326    * Since `Set`s only support integers or strings as values, we cannot have
327    * a `Pair` as a `Set` value. So in order to avoid an
328    * `InvalidArgumentException`, either the current `Set` or the `Traversable`
329    * must be empty so that we actually return an empty `Set`.
330    *
331    * @param $traversable - The `Traversable` to use to combine with the
332    *                       elements of the current `Set`.
333    *
334    * @return - The `Set` that combines the values of the current `Set` with
335    *           the provided `Traversable`; one of these must be empty or an
336    *           exception is thrown.
337    */
338   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
339   public function zip<Tu>(<<__MaybeMutable, __OnlyRxIfImpl(HH\Rx\Traversable::class)>> Traversable<Tu> $traversable): Set<Pair<Tv, Tu>>;
341   /**
342    * Returns a `Set` containing the first `n` values of the current `Set`.
343    *
344    * The returned `Set` will always be a proper subset of the current `Set`.
345    *
346    * `n` is 1-based. So the first element is 1, the second 2, etc.
347    *
348    * @param $n - The last element that will be included in the `Set`.
349    *
350    * @return - A `Set` that is a proper subset of the current `Set` up to `n`
351    *           elements.
352    */
353   <<__Rx, __MutableReturn, __MaybeMutable>>
354   public function take(int $n): Set<Tv>;
356   /**
357    * Returns a `Set` containing the values of the current `Set` up to but not
358    * including the first value that produces `false` when passed to the
359    * specified callback.
360    *
361    * The returned `Set` will always be a proper subset of the current `Set`.
362    *
363    * @param $fn - The callback that is used to determine the stopping condition.
364    *
365    * @return - A `Set` that is a proper subset of the current `Set` up until
366    *           the callback returns `false`.
367    */
368   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
369   public function takeWhile(<<__OnlyRxIfRxFunc>>(function(Tv): bool) $fn): Set<Tv>;
371   /**
372    * Returns a `Set` containing the values after the `n`-th element of the
373    * current `Set`.
374    *
375    * The returned `Set` will always be a proper subset of the current `Set`.
376    *
377    * `n` is 1-based. So the first element is 1, the second 2, etc.
378    *
379    * @param $n - The last element to be skipped; the `$n+1` element will be
380    *             the first one in the returned `Set`.
381    *
382    * @return - A `Set` that is a proper subset of the current `Set` containing
383    *           values after the specified `n`-th element.
384    */
385   <<__Rx, __MutableReturn, __MaybeMutable>>
386   public function skip(int $n): Set<Tv>;
388   /**
389    * Returns a `Set` containing the values of the current `Set` starting after
390    * and including the first value that produces `true` when passed to the
391    * specified callback.
392    *
393    * The returned `Set` will always be a proper subset of the current `Set`.
394    *
395    * @param $fn - The callback used to determine the starting element for the
396    *              `Set`.
397    *
398    * @return - A `Set` that is a proper subset of the current `Set` starting
399    *           after the callback returns `true`.
400    */
401   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
402   public function skipWhile(<<__OnlyRxIfRxFunc>>(function(Tv): bool) $fn): Set<Tv>;
404   /**
405    * Returns a subset of the current `Set` starting from a given key up to, but
406    * not including, the element at the provided length from the starting key.
407    *
408    * `$start` is 0-based. `$len` is 1-based. So `slice(0, 2)` would return the
409    * elements at key 0 and 1.
410    *
411    * The returned `Set` will always be a proper subset of the current `Set`.
412    *
413    * @param $start - The starting value in the current `Set` for the returned
414    *                 `Set`.
415    * @param $len - The length of the returned `Set`.
416    *
417    * @return - A `Set` that is a proper subset of the current `Set` starting at
418    *           `$start` up to but not including the element `$start + $len`.
419    */
420   <<__Rx, __MutableReturn, __MaybeMutable>>
421   public function slice(int $start, int $len): Set<Tv>;
423   /**
424    * Returns a `Vector` that is the concatenation of the values of the current
425    * `Set` and the values of the provided `Traversable`.
426    *
427    * The values of the provided `Traversable` is concatenated to the end of the
428    * current `Set` to produce the returned `Vector`.
429    *
430    * @param $traversable - The `Traversable` to concatenate to the current
431    *                       `Set`.
432    *
433    * @return - The concatenated `Vector`.
434    *
435    * @guide /hack/generics/constraints
436    */
437   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
438   public function concat<Tu super Tv>(<<__MaybeMutable, __OnlyRxIfImpl(HH\Rx\Traversable::class)>> Traversable<Tu> $traversable): Vector<Tu>;
440   /**
441    * Returns the first value in the current `Set`.
442    *
443    * @return - The first value in the current `Set`, or `null` if the `Set` is
444    *           empty.
445    */
446   <<__Rx, __MaybeMutable>>
447   public function firstValue(): ?Tv;
449   /**
450    * Returns the first "key" in the current `Set`.
451    *
452    * Since `Set`s do not have keys, it returns the first value.
453    *
454    * This method is interchangeable with `firstValue()`.
455    *
456    * @return - The first value in the current `Set`, or `null` if the `Set` is
457    *           empty.
458    */
459   <<__Rx, __MaybeMutable>>
460   public function firstKey(): ?arraykey;
462   /**
463    * Returns the last value in the current `Set`.
464    *
465    * @return - The last value in the current `Set`, or `null` if the current
466    *           `Set` is empty.
467    */
468   <<__Rx, __MaybeMutable>>
469   public function lastValue(): ?Tv;
471   /**
472    * Returns the last "key" in the current `Set`.
473    *
474    * Since `Set`s do not have keys, it returns the last value.
475    *
476    * This method is interchangeable with `lastValue()`.
477    *
478    * @return - The last value in the current `Set`, or `null` if the current
479    *           `Set` is empty.
480    */
481   <<__Rx, __MaybeMutable>>
482   public function lastKey(): ?arraykey;
484   /**
485    * Checks if the current `Set` is empty.
486    *
487    * @return - `true` if the current `Set` is empty; `false` otherwise.
488    */
489   <<__Rx, __MaybeMutable>>
490   public function isEmpty(): bool;
492   /**
493    * Provides the number of elements in the current `Set`.
494    *
495    * @return - The number of elements in the current `Set`.
496    */
497   <<__Rx, __MaybeMutable>>
498   public function count(): int;
500   /**
501    * Remove all the elements from the current `Set`.
502    *
503    * Future changes made to the current `Set` ARE reflected in the returned
504    * `Set`, and vice-versa.
505    *
506    * @return - Returns itself.
507    */
508   <<__Rx, __Mutable, __ReturnsVoidToRx>>
509   public function clear(): Set<Tv>;
511   /**
512    * Determines if the specified value is in the current `Set`.
513    *
514    * @param $v - The value to check.
515    * @return - `true` if the specified value is present in the current `Set`;
516    *           `false` otherwise.
517    */
518   <<__Rx, __MaybeMutable>>
519   public function contains<Tu super Tv>(Tu $v): bool;
521   /**
522    * Add the value to the current `Set`.
523    *
524    * `$set->add($v)` is semantically equivalent to `$set[] = $v` (except that
525    * `add()` returns the `Set`).
526    *
527    * Future changes made to the current `Set` ARE reflected in the returned
528    * `Set`, and vice-versa.
529    *
530    * @param $v - The value to add to the current `Set`
531    *
532    * @return - Returns itself.
533    */
534   <<__Rx, __Mutable, __ReturnsVoidToRx>>
535   public function add(Tv $v): Set<Tv>;
537   /**
538    * For every element in the provided `Traversable`, add the value into the
539    * current `Set`.
540    *
541    * Future changes made to the original `Set` ARE reflected in the returned
542    * `Set`, and vice-versa.
543    *
544    * @param $k - The `Traversable` with the new values to add. If `null` is
545    *             provided, no changes are made.
546    *
547    * @return - Returns itself.
548    */
549   <<__Rx, __Mutable, __OnlyRxIfArgs, __ReturnsVoidToRx>>
550   public function addAll(<<__MaybeMutable, __OnlyRxIfImpl(HH\Rx\Traversable::class)>> ?Traversable<Tv> $it): Set<Tv>;
552   /**
553    * Adds the keys of the specified container to the current `Set` as new
554    * values.
555    *
556    * Future changes made to the current `Set` ARE reflected in the returned
557    * `Set`, and vice-versa.
558    *
559    * @param $container - The container with the new keys to add.
560    *
561    * @return - Returns itself.
562    */
563   <<__Rx, __Mutable, __ReturnsVoidToRx>>
564   public function addAllKeysOf<Tv2>(
565     ?KeyedContainer<Tv,Tv2> $container,
566   ): Set<Tv>;
568   /**
569    * Reserves enough memory to accommodate a given number of elements.
570    *
571    * Reserves enough memory for `sz` elements. If `sz` is less than or equal
572    * to the current capacity of this `Set`, this method does nothing.
573    *
574    * @param $sz - The pre-determined size you want for the current `Set`.
575    */
576   <<__Rx, __Mutable>>
577   public function reserve(int $sz): void;
579   /**
580    * Removes the specified value from the current `Set`.
581    *
582    * Future changes made to the current `Set` ARE reflected in the returned
583    * `Set`, and vice-versa.
584    *
585    * @param $v - The value to remove.
586    *
587    * @return - Returns itself.
588    */
589   <<__Rx, __Mutable, __ReturnsVoidToRx>>
590   public function remove(Tv $v): Set<Tv>;
592   /**
593    * Removes the values in the current `Set` that are also in the `Traversable`.
594    *
595    * If a value in the `Traversable` doesn't exist in the current `Set`, that
596    * value in the `Traversable` is ignored.
597    *
598    * Future changes made to the current `Set` ARE reflected in the returned
599    * `Set`, and vice-versa.
600    *
601    * @param $other - The `Traversable` containing values that will be removed
602    *                 from the `Set`.
603    *
604    * @return - Returns itself.
605    */
606   <<__Rx, __Mutable, __OnlyRxIfArgs, __ReturnsVoidToRx>>
607   public function removeAll(<<__MaybeMutable, __OnlyRxIfImpl(HH\Rx\Traversable::class)>> Traversable<Tv> $other): Set<Tv>;
609   /**
610    * Returns an iterator that points to beginning of the current `Set`.
611    *
612    * @return - A `KeyedIterator` that allows you to traverse the current `Set`.
613    */
614   <<__Rx, __MutableReturn, __MaybeMutable>>
615   public function getIterator(): HH\Rx\KeyedIterator<arraykey, Tv>;
617   /**
618    * Returns a `Set` containing the values from the specified `array`.
619    *
620    * This function is deprecated. Use `new Set ($arr)` instead.
621    *
622    * @param $arr - The `array` to convert to a `Set`.
623    *
624    * @return - A `Set` with the values from the provided `array`.
625    */
626   <<__Deprecated('Use `new Set($arr)` instead.')>>
627   public static function fromArray<T>(darray<T, Tv> $arr): Set<Tv>;
629   /**
630    * Returns a `Set` containing all the values from the specified `array`(s).
631    *
632    * @param ... - The `array`s to convert to a `Set`.
633    *
634    * @return - A `Set` with the values from the passed `array`(s).
635    */
636   <<__Rx, __MutableReturn, __MaybeMutable>>
637   public static function fromArrays(...): Set<Tv>;
639   /**
640    * Creates a `Set` from the given `Traversable`, or an empty `Set` if `null`
641    * is passed.
642    *
643    * This is the static method version of the `Set::__construct()` constructor.
644    *
645    * @param $items - any `Traversable` object from which to create a `Set`
646    *                 (e.g., `array`). If `null`, then an empty `Set` is created.
647    *
648    * @return - A `Set` with the values from the `Traversable`; or an empty `Set`
649    *           if the `Traversable` is `null`.
650    */
651   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
652   public static function fromItems<Tv2>(<<__MaybeMutable, __OnlyRxIfImpl(HH\Rx\Traversable::class)>> ?Traversable<Tv2> $items): Set<Tv2>;
654   /**
655    * Creates a `Set` from the keys of the specified container.
656    *
657    * The keys of the container will be the values of the `Set`.
658    *
659    * @param $container - The container with the keys used to create the `Set`.
660    *
661    * @return - A `Set` built from the keys of the specified container.
662    */
663   <<__Rx, __MutableReturn, __MaybeMutable>>
664   public static function fromKeysOf<Tk, Tv2>(
665     ?KeyedContainer<Tk,Tv2> $container,
666   ): Set<Tk>;
668   /**
669    * Returns the `string` version of the current `Set`, which is `"Set"`.
670    *
671    * @return - The `string` `"Set"`.
672    */
673   <<__Rx, __MaybeMutable>>
674   public function __toString(): string;
676   /**
677    * Returns an `Iterable` view of the current `Set`.
678    *
679    * The `Iterable` returned is one that produces the values from the current
680    * `Set`.
681    *
682    * @return - The `Iterable` view of the current `Set`.
683    */
684   <<__Rx, __MutableReturn, __MaybeMutable>>
685   public function items(): HH\Rx\Iterable<Tv>;
687   <<__Rx, __MaybeMutable>> /* HH_FIXME[0002] */
688   public function toVArray(): varray<Tv>;
689   <<__Rx, __MaybeMutable>> /* HH_FIXME[0001] */
690   public function toDArray(): darray<Tv, Tv>;
694  * @internal
696  * Methods and functions should take and return the KeyedIterator interface.
697  */
698 class SetIterator<+Tv> implements HH\Rx\KeyedIterator<arraykey, Tv> {
699   <<__Rx>>
700   public function __construct();
701   <<__Rx, __MaybeMutable>>
702   public function current(): Tv;
703   <<__Rx, __MaybeMutable>>
704   public function key(): arraykey;
705   <<__Rx, __MaybeMutable>>
706   public function valid(): bool;
707   <<__Rx, __Mutable>>
708   public function next(): void;
709   <<__Rx, __Mutable>>
710   public function rewind(): void;