MaybeMutable the collection builtins
[hiphop-php.git] / hphp / hack / hhi / rx / interfaces.hhi
blob3948dd898fce12969392d53ef373bbf71e19ce11
1 <?hh // partial
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 hack's reactive interfaces
13  *
14  * YOU SHOULD NEVER INCLUDE THIS FILE ANYWHERE!!!
15  */
17 namespace HH\Rx;
19 /* See documentation for \Traversable */
20 <<__Sealed(
21   namespace\KeyedTraversable::class,
22   namespace\Iterator::class,
23   namespace\IteratorAggregate::class,
24   \Container::class
25 )>>
26 interface Traversable<+Tv> extends \Traversable<Tv> {}
28 /* See documentation for \KeyedTraversable */
29 <<__Sealed(
30   namespace\KeyedIterable::class,
31   namespace\KeyedIterator::class,
32   \KeyedContainer::class
33 )>>
34 interface KeyedTraversable<+Tk, +Tv>
35   extends namespace\Traversable<Tv>, \KeyedTraversable<Tk, Tv> {}
37 /* See documentation for \Iterator */
38 interface Iterator<+Tv> extends namespace\Traversable<Tv>, \Iterator<Tv> {
39   /**
40    * Return the current value at the current iterator position.
41    *
42    * @return - The current value of type `Tv`.
43    */
44   <<__Rx, __MaybeMutable>>
45   public function current(): Tv;
46   /**
47    * Move the iterator position to the next element.
48    *
49    */
50   <<__Rx, __Mutable>>
51   public function next(): void;
52   /**
53    * Rewind the iterator position to its beginning.
54    *
55    * This rewinds back to the first element of the `Iterator`.
56    */
57   <<__Rx, __Mutable>>
58   public function rewind(): void;
59   /**
60    * Checks to see if the current iterator position is valid.
61    *
62    * This method is called after `rewind()` and `next()` to check if the
63    * current iterator position is valid.
64    *
65    * @return - `true` if the position is valid; `false` otherwise.
66    */
67   <<__Rx, __MaybeMutable>>
68   public function valid(): bool;
71 interface KeyedIterator<+Tk, +Tv>
72   extends
73     namespace\KeyedTraversable<Tk, Tv>,
74     namespace\Iterator<Tv>,
75     \KeyedIterator<Tk, Tv> {
76   /**
77    * Return the current key at the current iterator position.
78    *
79    * @return - The current key of type `Tk`.
80    */
81   <<__Rx, __MaybeMutable>>
82   public function key(): Tk;
85 /* See documentation for \AsyncIterator */
86 interface AsyncIterator<+Tv> extends \AsyncIterator<Tv> {
87   /**
88    * Move the async iterator to the next `Awaitable` position.
89    *
90    * ```
91    * foreach ($async_iter await $async_iter->next() $value)
92    * ```
93    *
94    * The above is the longhand syntax for `await as $value`.
95    *
96    * @return - The next `Awaitable` in the iterator sequence.
97    */
98   <<__Rx, __Mutable>>
99   public function next(): Awaitable<?(mixed, Tv)>;
102 /* See documentation for \AsyncKeyedIterator */
103 interface AsyncKeyedIterator<+Tk, +Tv>
104   extends namespace\AsyncIterator<Tv>, \AsyncKeyedIterator<Tk, Tv> {
105   /**
106    * Move the async iterator to the next `Awaitable` position.
107    *
108    * ```
109    * foreach ($async_iter await $async_iter->next() $key=>$value)
110    * ```
111    *
112    * The above is the longhand syntax for `await as $key=>$value`.
113    *
114    * @return - The next `Awaitable` in the iterator sequence.
115    */
116   <<__Rx, __Mutable>>
117   public function next(): Awaitable<?(Tk, Tv)>;
120 /* See documentation for \IteratorAggregate */
121 interface IteratorAggregate<+Tv>
122   extends namespace\Traversable<Tv>, \IteratorAggregate<Tv> {
123   /**
124    * Returns an iterator to be used to iterate over the object's elements.
125    *
126    * @return - An `Iterator` for iteration.
127    */
128   <<__Rx, __MutableReturn, __MaybeMutable>>
129   public function getIterator(): namespace\Iterator<Tv>;
132 interface Iterable<+Tv>
133   extends namespace\IteratorAggregate<Tv>, \Iterable<Tv> {
134   /**
135    * Returns an iterator that points to beginning of the current `Iterable`.
136    *
137    * @return - An `Iterator` that allows you to traverse the current `Iterable`.
138    */
139   <<__Rx, __MutableReturn, __MaybeMutable>>
140   public function getIterator(): namespace\Iterator<Tv>;
141   /**
142    * Returns an `array` converted from the current `Iterable`.
143    *
144    * @return - an array converted from the current `Iterable`.
145    */
146   <<__Rx, __MaybeMutable>>
147   /* HH_IGNORE_ERROR[2082] T30260145 */
148   public function toArray(): array;
149   /**
150    * Returns an `array` with the values from the current `Iterable`.
151    *
152    * The keys in the current `Iterable` are discarded and replaced with integer
153    * indices, starting with 0.
154    *
155    * @return - an `array` containing the values from the current `Iterable`.
156    */
157   <<__Rx, __MaybeMutable>>
158   public function toValuesArray(): varray;
159   /**
160    * Returns a `Vector` converted from the current `Iterable`.
161    *
162    * Any keys in the current `Iterable` are discarded and replaced with integer
163    * indices, starting with 0.
164    *
165    * @return - a `Vector` converted from the current `Iterable`.
166    */
167   <<__Rx, __MutableReturn, __MaybeMutable>>
168   /* HH_FIXME[4120]: While this violates our variance annotations, we are
169    * returning a copy of the underlying collection, so it is actually safe
170    * See #6853603. */
171   public function toVector(): Vector<Tv>;
172   /**
173    * Returns an immutable vector (`ImmVector`) converted from the current
174    * `Iterable`.
175    *
176    * Any keys in the current `Iterable` are discarded and replaced with integer
177    * indices, starting with 0.
178    *
179    * @return - an `ImmVector` converted from the current `Iterable`.
180    */
181   <<__Rx, __MaybeMutable>>
182   public function toImmVector(): ImmVector<Tv>;
183   /**
184    * Returns a `Set` converted from the current `Iterable`.
185    *
186    * Any keys in the current `Iterable` are discarded.
187    *
188    * @return - a `Set` converted from the current `Iterable`.
189    */
190   <<__Rx, __MutableReturn, __MaybeMutable>>
191   /* HH_FIXME[4120]: While this violates our variance annotations, we are
192    * returning a copy of the underlying collection, so it is actually safe.
193    * See #6853603. */
194   public function toSet(): Set<Tv>;
195   /**
196    * Returns an immutable set (`ImmSet`) converted from the current `Iterable`.
197    *
198    * Any keys in the current `Iterable` are discarded.
199    *
200    * @return - an `ImmSet` converted from the current `Iterable`.
201    */
202   <<__Rx, __MaybeMutable>>
203   public function toImmSet(): ImmSet<Tv>;
204   /**
205    * Returns a lazy, access elements only when needed view of the current
206    * `Iterable`.
207    *
208    * Normally, memory is allocated for all of the elements of the `Iterable`.
209    * With a lazy view, memory is allocated for an element only when needed or
210    * used in a calculation like in `map()` or `filter()`.
211    *
212    * @return - an `Iterable` representing the lazy view into the current
213    *           `Iterable`.
214    *
215    * @guide /hack/collections/examples
216    */
217   <<__Rx, __MutableReturn, __MaybeMutable>>
218   public function lazy(): namespace\Iterable<Tv>;
219   /**
220    * Returns an `Iterable` containing the current `Iterable`'s values.
221    *
222    * Any keys are discarded.
223    *
224    * @return An `Iterable` with the values of the current `Iterable`.
225    */
226   <<__Rx, __MutableReturn, __MaybeMutable>>
227   public function values(): namespace\Iterable<Tv>;
228   /**
229    * Returns an `Iterable` containing the values after an operation has been
230    * applied to each value in the current `Iterable`.
231    *
232    * Every value in the current `Iterable` is affected by a call to `map()`,
233    * unlike `filter()` where only values that meet a certain criteria are
234    * affected.
235    *
236    * @param $fn - The callback containing the operation to apply to the
237    *              `Iterable` values.
238    *
239    * @return - an `Iterable` containing the values after a user-specified
240    *           operation is applied.
241    *
242    * @guide /hack/collections/examples
243    */
244   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
245   public function map<Tu>(
246     <<__OnlyRxIfRxFunc>>(function(Tv): Tu) $fn,
247   ): namespace\Iterable<Tu>;
248   /**
249    * Returns an `Iterable` containing the values of the current `Iterable` that
250    * meet a supplied condition.
251    *
252    * Only values that meet a certain criteria are affected by a call to
253    * `filter()`, while all values are affected by a call to `map()`.
254    *
255    * @param $fn - The callback containing the condition to apply to the
256    *              `Itearble` values.
257    *
258    * @return - an `Iterable` containing the values after a user-specified
259    *           condition is applied.
260    *
261    * @guide /hack/collections/examples
262    */
263   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
264   public function filter(
265     <<__OnlyRxIfRxFunc>>(function(Tv): bool) $fn,
266   ): namespace\Iterable<Tv>;
267   /**s
268    *  Returns an `Iterable` where each element is a `Pair` that combines the
269    *  element of the current `Iterable` and the provided `Traversable`.
270    *
271    *  If the number of elements of the `Iterable` are not equal to the number of
272    *  elements in the `Traversable`, then only the combined elements up to and
273    *  including the final element of the one with the least number of elements
274    *  is included.
275    *
276    *  @param $traversable - The `Traversable` to use to combine with the
277    *                        elements of the current `Iterable`.
278    *
279    *  @return - The `Iterable` that combines the values of the current
280    *            `Itearable` with the provided `Traversable`.
281    */
282   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
283   public function zip<Tu>(
284     <<__OnlyRxIfImpl(namespace\Traversable::class)>> \Traversable<Tu> $traversable,
285   ): namespace\Iterable<Pair<Tv, Tu>>;
286   /**
287    * Returns an `Iterable` containing the first `n` values of the current
288    * `Iterable`.
289    *
290    * The returned `Iterable` will always be a proper subset of the current
291    * `Iterable`.
292    *
293    * `$n` is 1-based. So the first element is 1, the second 2, etc.
294    *
295    * @param $n - The last element that will be included in the returned
296    *             `Iterable`.
297    *
298    * @return - An `Iterable that is a proper subset of the current `Iterable`
299    *           up to `n` elements.
300    */
301   <<__Rx, __MutableReturn, __MaybeMutable>>
302   public function take(int $n): namespace\Iterable<Tv>;
303   /**
304    * Returns an `Iterable` containing the values of the current `Iterable` up
305    * to but not including the first value that produces `false` when passed to
306    * the specified callback.
307    *
308    * The returned `Iterable` will always be a proper subset of the current
309    * `Iterable`.
310    *
311    * @param $fn - The callback that is used to determine the stopping
312    *              condition.
313    *
314    * @return - An `Iterable` that is a proper subset of the current `Iterable`
315    *           up until the callback returns `false`.
316    */
317   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
318   public function takeWhile(
319     <<__OnlyRxIfRxFunc>>(function(Tv): bool) $fn,
320   ): namespace\Iterable<Tv>;
321   /**
322    * Returns an `Iterable` containing the values after the `n`-th element of the
323    * current `Iterable`.
324    *
325    * The returned `Iterable` will always be a proper subset of the current
326    * `Iterable`.
327    *
328    * `$n` is 1-based. So the first element is 1, the second 2, etc.
329    *
330    * @param $n - The last element to be skipped; the `$n+1` element will be
331    *             the first one in the returned `Iterable`.
332    *
333    * @return - An `Iterable` that is a proper subset of the current `Iterable`
334    *           containing values after the specified `n`-th element.
335    */
336   <<__Rx, __MutableReturn, __MaybeMutable>>
337   public function skip(int $n): namespace\Iterable<Tv>;
338   /**
339    * Returns an `Iterable` containing the values of the current `Iterable`
340    * starting after and including the first value that produces `true` when
341    * passed to the specified callback.
342    *
343    * The returned `Iterable` will always be a proper subset of the current
344    * `Iterable`.
345    *
346    * @param $fn - The callback used to determine the starting element for the
347    *              returned `Iterable`.
348    *
349    * @return - An `Iterable` that is a proper subset of the current `Iterable`
350    *           starting after the callback returns `true`.
351    */
352   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
353   public function skipWhile(
354     <<__OnlyRxIfRxFunc>>(function(Tv): bool) $fn,
355   ): namespace\Iterable<Tv>;
356   /**
357    * Returns a subset of the current `Iterable` starting from a given key up
358    * to, but not including, the element at the provided length from the
359    * starting key.
360    *
361    * `$start` is 0-based. `$len` is 1-based. So `slice(0, 2)` would return the
362    * elements at key 0 and 1.
363    *
364    * The returned `Iterable` will always be a proper subset of the current
365    * `Iterable`.
366    *
367    * @param $start - The starting key of the current `Iterable` to begin the
368    *                 returned `Iterable`.
369    * @param $len - The length of the returned `Iterable`.
370    *
371    * @return - An `Iterable` that is a proper subset of the current `Iterable`
372    *           starting at `$start` up to but not including the element
373    *           `$start + $len`.
374    */
375   <<__Rx, __MutableReturn, __MaybeMutable>>
376   public function slice(int $start, int $len): namespace\Iterable<Tv>;
377   /**
378    * Returns an `Iterable` that is the concatenation of the values of the
379    * current `Iterable` and the values of the provided `Traversable`.
380    *
381    * The values of the provided `Traversable` is concatenated to the end of the
382    * current `Iterable` to produce the returned `Iterable`.
383    *
384    * @param $traversable - The `Traversable` to concatenate to the current
385    *                       `Iterable`.
386    *
387    * @return - The concatenated `Iterable`.
388    *
389    * @guide /hack/generics/constraints
390    */
391   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
392   public function concat<Tu super Tv>(
393     <<__OnlyRxIfImpl(namespace\Traversable::class)>> \Traversable<Tu> $traversable,
394   ): namespace\Iterable<Tu>;
395   /**
396    * Returns the first value in the current `Iterable`.
397    *
398    * @return - The first value in the current `Iterable`, or `null` if the
399    *           current `Iterable` is empty.
400    */
401   <<__Rx, __MaybeMutable>>
402   public function firstValue(): ?Tv;
403   /**
404    * Returns the last value in the current `Iterable`.
405    *
406    * @return - The last value in the current `Iterable`, or `null` if the
407    *           current `Iterable` is empty.
408    */
409   <<__Rx, __MaybeMutable>>
410   public function lastValue(): ?Tv;
413 interface KeyedIterable<Tk, +Tv>
414   extends
415     namespace\KeyedTraversable<Tk, Tv>,
416     namespace\Iterable<Tv>,
417     \KeyedIterable<Tk, Tv> {
418   /**
419    * Returns an iterator that points to beginning of the current
420    * `KeyedIterable`.
421    *
422    * @return - A `KeyedIterator` that allows you to traverse the current
423    *           `KeyedIterable`.
424    */
425   <<__Rx, __MutableReturn, __MaybeMutable>>
426   public function getIterator(): namespace\KeyedIterator<Tk, Tv>;
427   /**
428    * Returns an `array` with the keys from the current `KeyedIterable`.
429    *
430    * @return - an `array` containing the values from the current
431    *           `KeyedIterable`.
432    */
433   <<__Rx, __MaybeMutable>>
434   public function toKeysArray(): varray;
435   /**
436    * Returns a `Map` based on the keys and values of the current
437    * `KeyedIterable`.
438    *
439    * @return - a `Map` that has the keys and associated values of the current
440    *           `KeyedIterable`.
441    */
442   <<__Rx, __MutableReturn, __MaybeMutable>>
443   /* HH_FIXME[4120]: While this violates our variance annotations, we are
444    * returning a copy of the underlying collection, so it is actually safe
445    * See #6853603. */
446   public function toMap(): \Map<Tk, Tv>;
447   /**
448    * Returns an immutable map (`ImmMap`) based on the keys and values of the
449    * current `KeyedIterable`.
450    *
451    * @return - an `ImmMap` that has the keys and associated values of the
452    *           current `KeyedIterable`.
453    */
454   <<__Rx, __MaybeMutable>>
455   public function toImmMap(): \ImmMap<Tk, Tv>;
456   /**
457    * Returns a lazy, access elements only when needed view of the current
458    * `KeyedIterable`.
459    *
460    * Normally, memory is allocated for all of the elements of the
461    * `KeyedIterable`. With a lazy view, memory is allocated for an element only
462    * when needed or used in a calculation like in `map()` or `filter()`.
463    *
464    * @return - a `KeyedIterable` representing the lazy view into the current
465    *           `KeyedIterable`.
466    *
467    * @guide /hack/collections/examples
468    */
469   <<__Rx, __MutableReturn, __MaybeMutable>>
470   public function lazy(): namespace\KeyedIterable<Tk, Tv>;
471   /**
472    * Returns an `Iterable` containing the current `KeyedIterable`'s values.
473    *
474    * Any keys are discarded.
475    *
476    * @return An `Iterable` with the values of the current `KeyedIterable`.
477    */
478   <<__Rx, __MutableReturn, __MaybeMutable>>
479   public function values(): namespace\Iterable<Tv>;
480   /**
481    * Returns an `Iterable` containing the current `KeyedIterable`'s keys.
482    *
483    * Any values are discarded.
484    *
485    * @return An `Iterable` with the keys of the current `KeyedIterable`.
486    */
487   <<__Rx, __MutableReturn, __MaybeMutable>>
488   public function keys(): namespace\Iterable<Tk>;
489   /**
490    * Returns a `KeyedIterable` containing the values after an operation has been
491    * applied to each value in the current `KeyedIterable`.
492    *
493    * Every value in the current `KeyedIterable` is affected by a call to
494    * `map()`, unlike `filter()` where only values that meet a certain criteria
495    * are affected.
496    *
497    * @param $fn - The callback containing the operation to apply to the
498    *              `KeyedIterable` values.
499    *
500    * @return - a `KeyedIterable` containing the values after a user-specified
501    *           operation is applied.
502    *
503    * @guide /hack/collections/examples
504    */
505   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
506   public function map<Tu>(
507     <<__OnlyRxIfRxFunc>>(function(Tv): Tu) $fn,
508   ): namespace\KeyedIterable<Tk, Tu>;
509   /**
510    * Returns a `KeyedIterable` containing the values after an operation has
511    * been applied to each key and value in the current `KeyedIterable`.
512    *
513    * Every key and value in the current `KeyedIterable` is affected by a call to
514    * `mapWithKey()`, unlike `filterWithKey()` where only values that meet a
515    * certain criteria are affected.
516    *
517    * @param $fn - The callback containing the operation to apply to the
518    *              `KeyedIterable` keys and values.
519    *
520    * @return - a `KeyedIterable` containing the values after a user-specified
521    *           operation on the current `KeyedIterable`'s keys and values is
522    *           applied.
523    */
524   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
525   public function mapWithKey<Tu>(
526     <<__OnlyRxIfRxFunc>>(function(Tk, Tv): Tu) $fn,
527   ): namespace\KeyedIterable<Tk, Tu>;
528   /**
529    * Returns a `KeyedIterable` containing the values of the current
530    * `KeyedIterable` that meet a supplied condition.
531    *
532    * Only values that meet a certain criteria are affected by a call to
533    * `filter()`, while all values are affected by a call to `map()`.
534    *
535    * @param $fn - The callback containing the condition to apply to the
536    *              `KeyedItearble` values.
537    *
538    * @return - a `KeyedIterable` containing the values after a user-specified
539    *           condition is applied.
540    *
541    * @guide /hack/collections/examples
542    */
543   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
544   public function filter(
545     <<__OnlyRxIfRxFunc>>(function(Tv): bool) $fn,
546   ): namespace\KeyedIterable<Tk, Tv>;
547   /**
548    * Returns a `KeyedIterable` containing the values of the current
549    * `KeyedIterable` that meet a supplied condition applied to its keys and
550    * values.
551    *
552    * Only keys and values that meet a certain criteria are affected by a call to
553    * `filterWithKey()`, while all values are affected by a call to
554    * `mapWithKey()`.
555    *
556    * @param $fn - The callback containing the condition to apply to the
557    *              `KeyedIterable` keys and values.
558    *
559    * @return - a `KeyedIterable` containing the values after a user-specified
560    *           condition is applied to the keys and values of the current
561    *           `KeyedIterable`.
562    *
563    */
564   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
565   public function filterWithKey(
566     <<__OnlyRxIfRxFunc>>(function(Tk, Tv): bool) $fn,
567   ): namespace\KeyedIterable<Tk, Tv>;
568   /**
569    *  Returns a `KeyedIterable` where each element is a `Pair` that combines the
570    *  element of the current `KeyedIterable` and the provided `Traversable`.
571    *
572    *  If the number of elements of the `KeyedIterable` are not equal to the
573    *  number of elements in the `Traversable`, then only the combined elements
574    *  up to and including the final element of the one with the least number of
575    *  elements is included.
576    *
577    *  @param $traversable - The `Traversable` to use to combine with the
578    *                        elements of the current `KeyedIterable`.
579    *
580    *  @return - The `KeyedIterable` that combines the values of the current
581    *            `KeyedItearable` with the provided `Traversable`.
582    */
583   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
584   public function zip<Tu>(
585     <<__OnlyRxIfImpl(namespace\Traversable::class)>> \Traversable<Tu> $traversable,
586   ): namespace\KeyedIterable<Tk, Pair<Tv, Tu>>;
587   /**
588    * Returns a `KeyedIterable` containing the first `n` values of the current
589    * `KeyedIterable`.
590    *
591    * The returned `KeyedIterable` will always be a proper subset of the current
592    * `Iterable`.
593    *
594    * `$n` is 1-based. So the first element is 1, the second 2, etc.
595    *
596    * @param $n - The last element that will be included in the returned
597    *             `KeyedIterable`.
598    *
599    * @return - A `KeyedIterable that is a proper subset of the current
600    *           `KeyedIterable` up to `n` elements.
601    */
602   <<__Rx, __MutableReturn, __MaybeMutable>>
603   public function take(int $n): namespace\KeyedIterable<Tk, Tv>;
604   /**
605    * Returns a `KeyedIterable` containing the values of the current
606    * `KeyedIterable` up to but not including the first value that produces
607    * `false` when passed to the specified callback.
608    *
609    * The returned `KeyedIterable` will always be a proper subset of the current
610    * `KeyedIterable`.
611    *
612    * @param $fn - The callback that is used to determine the stopping
613    *              condition.
614    *
615    * @return - A `KeyedIterable` that is a proper subset of the current
616    *           `KeyedIterable` up until the callback returns `false`.
617    */
618   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
619   public function takeWhile(
620     <<__OnlyRxIfRxFunc>>(function(Tv): bool) $fn,
621   ): namespace\KeyedIterable<Tk, Tv>;
622   /**
623    * Returns a `KeyedIterable` containing the values after the `n`-th element
624    * of the current `KeyedIterable`.
625    *
626    * The returned `KeyedIterable` will always be a proper subset of the current
627    * `KeyedIterable`.
628    *
629    * `$n` is 1-based. So the first element is 1, the second 2, etc.
630    *
631    * @param $n - The last element to be skipped; the `$n+1` element will be
632    *             the first one in the returned `KeyedIterable`.
633    *
634    * @return - A `KeyedIterable` that is a proper subset of the current
635    *           `KeyedIterable`  containing values after the specified `n`-th
636    *           element.
637    */
638   <<__Rx, __MutableReturn, __MaybeMutable>>
639   public function skip(int $n): namespace\KeyedIterable<Tk, Tv>;
640   /**
641    * Returns a `KeyedIterable` containing the values of the current
642    * `KeyedIterable` starting after and including the first value that produces
643    * `true` when passed to the specified callback.
644    *
645    * The returned `KeyedIterable` will always be a proper subset of the current
646    * `KeyedIterable`.
647    *
648    * @param $fn - The callback used to determine the starting element for the
649    *              returned `KeyedIterable`.
650    *
651    * @return - A `KeyedIterable` that is a proper subset of the current
652    *           `KeyedIterable` starting after the callback returns `true`.
653    */
654   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
655   public function skipWhile(
656     <<__OnlyRxIfRxFunc>>(function(Tv): bool) $fn,
657   ): namespace\KeyedIterable<Tk, Tv>;
658   /**
659    * Returns a subset of the current `KeyedIterable` starting from a given key
660    * up to, but not including, the element at the provided length from the
661    * starting key.
662    *
663    * `$start` is 0-based. `$len` is 1-based. So `slice(0, 2)` would return the
664    * elements at key 0 and 1.
665    *
666    * The returned `KeyedIterable` will always be a proper subset of the current
667    * `KeyedIterable`.
668    *
669    * @param $start - The starting key of the current `KeyedIterable` to begin
670    *                 the returned `KeyedIterable`.
671    * @param $len - The length of the returned `KeyedIterable`.
672    *
673    * @return - A `KeyedIterable` that is a proper subset of the current
674    *           `KeyedIterable` starting at `$start` up to but not including the
675    *           element `$start + $len`.
676    */
677   <<__Rx, __MutableReturn, __MaybeMutable>>
678   public function slice(int $start, int $len): namespace\KeyedIterable<Tk, Tv>;
679   /**
680    * Returns an `Iterable` that is the concatenation of the values of the
681    * current `KeyedIterable` and the values of the provided `Traversable`.
682    *
683    * The values of the provided `Traversable` is concatenated to the end of the
684    * current `KeyedIterable` to produce the returned `Iterable`.
685    *
686    * @param $traversable - The `Traversable` to concatenate to the current
687    *                       `KeyedIterable`.
688    *
689    * @return - The concatenated `Iterable`.
690    *
691    * @guide /hack/generics/constraints
692    */
693   <<__Rx, __OnlyRxIfArgs, __MutableReturn, __MaybeMutable>>
694   public function concat<Tu super Tv>(
695     <<__OnlyRxIfImpl(namespace\Traversable::class)>> \Traversable<Tu> $traversable,
696   ): namespace\Iterable<Tu>;
697   /**
698    * Returns the first value in the current `KeyedIterable`.
699    *
700    * @return - The first value in the current `KeyedIterable`, or `null` if the
701    *           current `KeyedIterable` is empty.
702    */
703   <<__Rx, __MaybeMutable>>
704   public function firstValue(): ?Tv;
705   /**
706    * Returns the first key in the current `KeyedIterable`.
707    *
708    * @return - The first key in the current `KeyedIterable`, or `null` if the
709    *           current `KeyedIterable` is empty.
710    */
711   <<__Rx, __MaybeMutable>>
712   public function firstKey(): ?Tk;
713   /**
714    * Returns the last value in the current `KeyedIterable`.
715    *
716    * @return - The last value in the current `KeyedIterable`, or `null` if the
717    *           current `KeyedIterable` is empty.
718    */
719   <<__Rx, __MaybeMutable>>
720   public function lastValue(): ?Tv;
721   /**
722    * Returns the last key in the current `KeyedIterable`.
723    *
724    * @return - The last key in the current `KeyedIterable`, or `null` if the
725    *           current `KeyedIterable` is empty.
726    */
727   <<__Rx, __MaybeMutable>>
728   public function lastKey(): ?Tk;
731 interface Countable extends \Countable {
732   <<__Rx, __MaybeMutable>>
733   public function count(): int;