# Sequence Operations

Site [llms.txt](/gatherers4j/llms.txt)

---

Gatherers that reorder, combine, or manipulate the sequence of elements.


### Gatherers

| Function | Description |
|---|---|
| [crossWith()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/crosswith/index.md) | Cross every element of the input stream with every element of the given source, emitting them to the output stream as a `Pair<INPUT, CROSS>`. |
| [foldIndexed()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/foldindexed/index.md) | Perform a fold over every element in the input stream along with its index. |
| [interleaveWith()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/interleavewith/index.md) | Create a stream of alternating objects from the input stream and the argument source. |
| [intersperse()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/intersperse/index.md) | Put the given element between each pair of adjacent elements in the input stream. |
| [mapIndexed()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/mapindexed/index.md) | Perform a mapping operation given the element being mapped and its zero-based index. |
| [orderByFrequency()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/orderbyfrequency/index.md) | Emit elements in the input stream ordered by the specified frequency. |
| [peekIndexed()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/peekindexed/index.md) | Peek at each element of the stream along with its zero-based index. |
| [repeat()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/repeat/index.md) | Repeatedly emit the input stream to the output stream a given number of times. |
| [repeatInfinitely()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/repeatinfinitely/index.md) | Repeatedly emit the input stream to the output stream, infinitely. |
| [reverse()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/reverse/index.md) | Reverse the order of the input stream. |
| [rotate()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/rotate/index.md) | Consume the entire stream and emit its elements rotated either left or right `distance` number of spaces. |
| [scanIndexed()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/scanindexed/index.md) | Perform a scan over every element in the input stream along with its index. |
| [shuffle()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/shuffle/index.md) | Shuffle the input stream into a random order. |
| [throttle()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/throttle/index.md) | Limit the number of elements in the stream to some number per period. When the limit is reached, consumption is paused until a new period starts and the count resets. |
| [withIndex()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/withindex/index.md) | Maps all elements of the stream as-is along with their 0-based index. |
| [zipWith()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/zipwith/index.md) | Creates a stream of `Pair<FIRST,SECOND>` objects whose values come from the input stream and the source of arguments provided. |
| [zipWithNext()](https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/zipwithnext/index.md) | Creates a stream of `List` objects which contain each two adjacent elements in the input stream. |

---

Section pages:

- [crossWith()](/gatherers4j/gatherers/sequence-operations/crosswith/): Cross every element of the input stream with every element of the given source, emitting them to the output stream as a `Pair<INPUT, CROSS>`.
- [foldIndexed()](/gatherers4j/gatherers/sequence-operations/foldindexed/): Perform a fold over every element in the input stream along with its index.
- [interleaveWith()](/gatherers4j/gatherers/sequence-operations/interleavewith/): Create a stream of alternating objects from the input stream and the argument source.
- [intersperse()](/gatherers4j/gatherers/sequence-operations/intersperse/): Put the given element between each pair of adjacent elements in the input stream.
- [mapIndexed()](/gatherers4j/gatherers/sequence-operations/mapindexed/): Perform a mapping operation given the element being mapped and its zero-based index.
- [orderByFrequency()](/gatherers4j/gatherers/sequence-operations/orderbyfrequency/): Emit elements in the input stream ordered by the specified frequency.
- [peekIndexed()](/gatherers4j/gatherers/sequence-operations/peekindexed/): Peek at each element of the stream along with its zero-based index.
- [repeat()](/gatherers4j/gatherers/sequence-operations/repeat/): Repeatedly emit the input stream to the output stream a given number of times.
- [repeatInfinitely()](/gatherers4j/gatherers/sequence-operations/repeatinfinitely/): Repeatedly emit the input stream to the output stream, infinitely.
- [reverse()](/gatherers4j/gatherers/sequence-operations/reverse/): Reverse the order of the input stream.
- [rotate()](/gatherers4j/gatherers/sequence-operations/rotate/): Consume the entire stream and emit its elements rotated either left or right `distance` number of spaces.
- [scanIndexed()](/gatherers4j/gatherers/sequence-operations/scanindexed/): Perform a scan over every element in the input stream along with its index.
- [shuffle()](/gatherers4j/gatherers/sequence-operations/shuffle/): Shuffle the input stream into a random order.
- [throttle()](/gatherers4j/gatherers/sequence-operations/throttle/): Limit the number of elements in the stream to some number per period. When the limit is reached, consumption is paused until a new period starts and the count resets.
- [withIndex()](/gatherers4j/gatherers/sequence-operations/withindex/): Maps all elements of the stream as-is along with their 0-based index.
- [zipWith()](/gatherers4j/gatherers/sequence-operations/zipwith/): Creates a stream of `Pair<FIRST,SECOND>` objects whose values come from the input stream and the source of arguments provided.
- [zipWithNext()](/gatherers4j/gatherers/sequence-operations/zipwithnext/): Creates a stream of `List` objects which contain each two adjacent elements in the input stream.
