# Gatherers

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

---

The gatherers in this library are categorized into five groups to make things easier to find and understand.

**[Sequence Operations](/gatherers4j/gatherers/sequence-operations/)** which reorder, combine, or manipulate the sequence of elements.

**[Filtering and Selection](/gatherers4j/gatherers/filtering-and-selection/)** which select or remove elements based on some criteria.

**[Grouping and Windowing](/gatherers4j/gatherers/grouping-and-windowing/)** which collect elements into groups or windows.

**[Mathematical Operations](/gatherers4j/gatherers/mathematical/)** which perform calculations over the stream.

**[Validation and Constraints](/gatherers4j/gatherers/validation-and-constraints/)** which enforce conditions on the stream.

## Full List of Gatherers


| Title | 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>`. |
| [`debounce()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/debounce/index.md) | Limit the number of elements in the stream to some number per period, dropping anything over the limit during the period. |
| [`dedupeConsecutive()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/dedupeconsecutive/index.md) | Remove consecutive duplicate elements from a stream where equality is measured by `Object::equals()`. |
| [`dedupeConsecutiveBy()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/dedupeconsecutiveby/index.md) | Remove consecutive duplicates, where equality is measured by a given function. |
| [`distinctBy()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/distinctby/index.md) | Filter a stream such that it only contains distinct elements as measured by the given `mappingFunction`. |
| [`dropEveryNth()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/dropeverynth/index.md) | Drop every `n`th element of the stream. |
| [`dropLast()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/droplast/index.md) | Keep all elements except the last `count` elements of the stream. |
| [`ensureOrdered()`](https://tginsberg.github.io/gatherers4j/gatherers/validation-and-constraints/ensureordered/index.md) | Ensure that the `Comparable` elements in the input stream are in the order specified, and fail exceptionally if they are not. |
| [`ensureOrderedBy()`](https://tginsberg.github.io/gatherers4j/gatherers/validation-and-constraints/ensureorderedby/index.md) | Ensure that the elements in the input stream are in the order specified, as measured by the given `Comparator`, and fail exceptionally if they are not. |
| [`ensureSize()`](https://tginsberg.github.io/gatherers4j/gatherers/validation-and-constraints/ensuresize/index.md) | Ensure the input stream is the proper `length` as specified by `size`. |
| [`exponentialMovingAverageWithAlpha()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/exponentialmovingaveragewithalpha/index.md) | Create an exponential average of `BigDecimal` values, with the given `alpha`. |
| [`exponentialMovingAverageWithAlphaBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/exponentialmovingaveragewithalphaby/index.md) | Calculate the exponential moving average of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` with the given `alpha`. |
| [`exponentialMovingAverageWithPeriod()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/exponentialmovingaveragewithperiod/index.md) | Create an exponential average of `BigDecimal` values, over the given number of `periods`. |
| [`exponentialMovingAverageWithPeriodBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/exponentialmovingaveragewithperiodby/index.md) | Calculate the exponential moving average of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` over the given number of `periods`. |
| [`filterIndexed()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/filterindexed/index.md) | Filter a stream according to a given `predicate`, which takes both the item being examined and its index. |
| [`filterInstanceOf()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/filterinstanceof/index.md) | Filter the elements in the stream to only include elements of the given types. |
| [`filterNotNull()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/filternotnull/index.md) | Remove null elements from a stream, narrowing the output type to non-null. |
| [`filterOrdered()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/filterordered/index.md) | Filter the input stream so that it contains `Comparable<INPUT>` elements in the order provided. |
| [`filterOrderedBy()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/filterorderedby/index.md) | Filter the input stream so that it contains elements the order specified as measured by the given `Comparator`. |
| [`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. |
| [`group()`](https://tginsberg.github.io/gatherers4j/gatherers/grouping-and-windowing/group/index.md) | Turn a `Stream<INPUT>` into a `Stream<List<INPUT>>` where adjacent equal elements are in the same `List` and equality is measured by `Object::equals()`. |
| [`groupBy()`](https://tginsberg.github.io/gatherers4j/gatherers/grouping-and-windowing/groupby/index.md) | Turn a `Stream<INPUT>` into a `Stream<List<INPUT>>` where adjacent equal elements are in the same `List` and equality is measured by the given `mappingFunction`. |
| [`groupOrdered()`](https://tginsberg.github.io/gatherers4j/gatherers/grouping-and-windowing/groupordered/index.md) | Convert the input stream of `Comparable` objects into lists of ordered objects. |
| [`groupOrderedBy()`](https://tginsberg.github.io/gatherers4j/gatherers/grouping-and-windowing/grouporderedby/index.md) | Convert the input stream of objects into lists of ordered objects, as measured by the given `Comparator`. |
| [`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. |
| [`movingGeometricMean()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movinggeometricmean/index.md) | Calculate the moving geometric mean of a `Stream<BigDecimal>` looking back `windowSize` elements. |
| [`movingGeometricMeanBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movinggeometricmeanby/index.md) | Calculate the moving geometric mean of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`movingHarmonicMean()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingharmonicmean/index.md) | Calculate the moving harmonic mean of a `Stream<BigDecimal>` looking back `windowSize` elements. |
| [`movingHarmonicMeanBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingharmonicmeanby/index.md) | Calculate the moving harmonic mean of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`movingMax()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingmax/index.md) | Create a Stream that represents the moving maximum of a `Stream<T>` looking back `windowSize` elements. |
| [`movingMaxBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingmaxby/index.md) | Create a Stream that represents the moving maximum of a `Stream<T>` looking back `windowSize` elements, as calculated by the given `Comparator`. |
| [`movingMean()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingmean/index.md) | Calculate the moving mean of `BigDecimal` values over the previous `windowSize` number of values. |
| [`movingMeanBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingmeanby/index.md) | Calculate the moving mean of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` and looking back `windowSize` elements. |
| [`movingMedian()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingmedian/index.md) | Create a Stream that represents the moving median of a `Stream<BigDecimal>` looking back `windowSize` elements. |
| [`movingMedianBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingmedianby/index.md) | Create a Stream that represents the moving median of `BigDecimal` objects mapped from a `Stream<INPUT>` via a function and looking back `windowSize` elements. |
| [`movingMin()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingmin/index.md) | Create a Stream that represents the moving minimum of a `Stream<T>` looking back `windowSize` elements. |
| [`movingMinBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingminby/index.md) | Create a Stream that represents the moving minimum of a `Stream<T>` looking back `windowSize` elements, as calculated by the given `Comparator`. |
| [`movingPercentile()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingpercentile/index.md) | Create a Stream that represents the moving percentile of a `Stream<BigDecimal>` looking back `windowSize` elements. |
| [`movingPercentileBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingpercentileby/index.md) | Create a Stream that represents the moving percentile of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`, looking back `windowSize` elements. |
| [`movingProduct()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingproduct/index.md) | Calculate the moving product of a `Stream<BigDecimal>` looking back `windowSize` elements. |
| [`movingProductBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingproductby/index.md) | Calculate the moving product of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` and looking back `windowSize` elements. |
| [`movingRootMeanSquare()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingrootmeansquare/index.md) | Calculate the moving root mean square (quadratic mean) of a `Stream<BigDecimal>` looking back `windowSize` elements. |
| [`movingRootMeanSquareBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingrootmeansquareby/index.md) | Calculate the moving root mean square (quadratic mean) of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`movingStandardDeviation()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingstandarddeviation/index.md) | Calculate the moving standard deviation of a `Stream<BigDecimal>` looking back `windowSize` elements, as either a population or a sample. |
| [`movingStandardDeviationBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingstandarddeviationby/index.md) | Calculate the moving standard deviation of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` and looking back `windowSize` elements, as either a population or a sample. |
| [`movingStatistics()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingstatistics/index.md) | Calculate summary statistics (count, sum, mean, min, max, variance, and standard deviation) of a `Stream<BigDecimal>` looking back `windowSize` elements. |
| [`movingStatisticsBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingstatisticsby/index.md) | Calculate summary statistics (count, sum, mean, min, max, variance, and standard deviation) of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`, looking back `windowSize` elements. |
| [`movingSum()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingsum/index.md) | Calculate the moving sum of a `Stream<BigDecimal>` looking back `windowSize` elements. |
| [`movingSumBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingsumby/index.md) | Calculate the moving sum of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` and looking back `windowSize` elements. |
| [`movingVariance()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingvariance/index.md) | Calculate the moving variance of a `Stream<BigDecimal>` looking back `windowSize` elements, as either a population or a sample. |
| [`movingVarianceBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingvarianceby/index.md) | Calculate the moving variance of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` and looking back `windowSize` elements, as either a population or a sample. |
| [`movingWeightedMean()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingweightedmean/index.md) | Calculate the weighted moving mean of `BigDecimal` values over the previous `windowSize` number of values, giving newer values more weight. |
| [`movingWeightedMeanBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/movingweightedmeanby/index.md) | Calculate the weighted moving mean of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` and looking back `windowSize` elements, giving newer values more weight. |
| [`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. |
| [`runningGeometricMean()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runninggeometricmean/index.md) | Calculate the running geometric mean of a `Stream<BigDecimal>`. |
| [`runningGeometricMeanBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runninggeometricmeanby/index.md) | Calculate the running geometric mean of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`runningHarmonicMean()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningharmonicmean/index.md) | Calculate the running harmonic mean of a `Stream<BigDecimal>`. |
| [`runningHarmonicMeanBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningharmonicmeanby/index.md) | Calculate the running harmonic mean of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`runningMax()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningmax/index.md) | Calculate the running maximum value of a `Stream<Comparable<T>>`. |
| [`runningMaxBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningmaxby/index.md) | Calculate the running maximum value of a `Stream<T>`, as calculated by the given `Comparator`. |
| [`runningMean()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningmean/index.md) | Calculate the running mean of a `Stream<BigDecimal>`. |
| [`runningMeanBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningmeanby/index.md) | Calculate the running mean of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`runningMedian()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningmedian/index.md) | Calculate the running median of a `Stream<BigDecimal>`. |
| [`runningMedianBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningmedianby/index.md) | Calculate the running median of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`runningMin()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningmin/index.md) | Calculate the running minimum value of a `Stream<Comparable<T>>`. |
| [`runningMinBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningminby/index.md) | Calculate the running minimum value of a `Stream<T>`, as calculated by the given `Comparator`. |
| [`runningPercentile()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningpercentile/index.md) | Calculate the running percentile of a `Stream<BigDecimal>`. |
| [`runningPercentileBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningpercentileby/index.md) | Calculate the running percentile of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`runningProduct()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningproduct/index.md) | Calculate the running product of a `Stream<BigDecimal>`. |
| [`runningProductBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningproductby/index.md) | Calculate the running product of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`runningRootMeanSquare()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningrootmeansquare/index.md) | Calculate the running root mean square (quadratic mean) of a `Stream<BigDecimal>`. |
| [`runningRootMeanSquareBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningrootmeansquareby/index.md) | Calculate the running root mean square (quadratic mean) of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`runningStandardDeviation()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningstandarddeviation/index.md) | Calculate the running standard deviation of a `Stream<BigDecimal>`, as either a population or a sample. |
| [`runningStandardDeviationBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningstandarddeviationby/index.md) | Calculate the running standard deviation of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`, as either a population or a sample. |
| [`runningStatistics()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningstatistics/index.md) | Calculate summary statistics (count, sum, mean, min, max, variance, and standard deviation) of a `Stream<BigDecimal>` so far. |
| [`runningStatisticsBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningstatisticsby/index.md) | Calculate summary statistics (count, sum, mean, min, max, variance, and standard deviation) of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction` so far. |
| [`runningSum()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningsum/index.md) | Calculate the running sum of a `Stream<BigDecimal>`. |
| [`runningSumBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningsumby/index.md) | Calculate the running sum of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`. |
| [`runningVariance()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningvariance/index.md) | Calculate the running variance of a `Stream<BigDecimal>`, as either a population or a sample. |
| [`runningVarianceBy()`](https://tginsberg.github.io/gatherers4j/gatherers/mathematical/runningvarianceby/index.md) | Calculate the running variance of `BigDecimal` objects mapped from a `Stream<INPUT>` via a `mappingFunction`, as either a population or a sample. |
| [`sampleFixedSize()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/samplefixedsize/index.md) | Perform a fixed-size sampling over the input stream. |
| [`samplePercentage()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/samplepercentage/index.md) | Perform a percentage-based sampling over the input stream. |
| [`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. |
| [`takeEveryNth()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/takeeverynth/index.md) | Take every `n`th element of the stream. |
| [`takeLast()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/takelast/index.md) | Remove all but the last `count` elements from the stream. |
| [`takeUntil()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/takeuntil/index.md) | Take elements from the input stream until the `predicate` is met, including the first element that matches the `predicate`. |
| [`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. |
| [`uniquelyOccurring()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/uniquelyoccurring/index.md) | Emit only those elements that occur in the input stream a single time. |
| [`uniquelyOccurringBy()`](https://tginsberg.github.io/gatherers4j/gatherers/filtering-and-selection/uniquelyoccurringby/index.md) | Emit only those elements that occur in the input stream a single time, as measured by the given function. |
| [`window()`](https://tginsberg.github.io/gatherers4j/gatherers/grouping-and-windowing/window/index.md) | Create windows over the elements of the input stream that are `windowSize` in length, sliding over `stepping` elements and optionally including partial windows at the end of the stream. |
| [`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:

- [Sequence Operations](/gatherers4j/gatherers/sequence-operations/)
- [Filtering and Selection](/gatherers4j/gatherers/filtering-and-selection/)
- [Grouping and Windowing](/gatherers4j/gatherers/grouping-and-windowing/)
- [Mathematical Operations](/gatherers4j/gatherers/mathematical/)
- [Validation and Constraints](/gatherers4j/gatherers/validation-and-constraints/)
