# Filtering and Selection

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

---

Gatherers that select or remove elements based on some criteria.


### Gatherers

| Function | Description |
|---|---|
| [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. |
| [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`. |
| [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. |
| [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`. |
| [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. |

---

Section pages:

- [debounce()](/gatherers4j/gatherers/filtering-and-selection/debounce/): Limit the number of elements in the stream to some number per period, dropping anything over the limit during the period.
- [dedupeConsecutive()](/gatherers4j/gatherers/filtering-and-selection/dedupeconsecutive/): Remove consecutive duplicate elements from a stream where equality is measured by `Object::equals()`.
- [dedupeConsecutiveBy()](/gatherers4j/gatherers/filtering-and-selection/dedupeconsecutiveby/): Remove consecutive duplicates, where equality is measured by a given function.
- [distinctBy()](/gatherers4j/gatherers/filtering-and-selection/distinctby/): Filter a stream such that it only contains distinct elements as measured by the given `mappingFunction`.
- [dropEveryNth()](/gatherers4j/gatherers/filtering-and-selection/dropeverynth/): Drop every `n`th element of the stream.
- [dropLast()](/gatherers4j/gatherers/filtering-and-selection/droplast/): Keep all elements except the last `count` elements of the stream.
- [filterIndexed()](/gatherers4j/gatherers/filtering-and-selection/filterindexed/): Filter a stream according to a given `predicate`, which takes both the item being examined and its index.
- [filterInstanceOf()](/gatherers4j/gatherers/filtering-and-selection/filterinstanceof/): Filter the elements in the stream to only include elements of the given types.
- [filterNotNull()](/gatherers4j/gatherers/filtering-and-selection/filternotnull/): Remove null elements from a stream, narrowing the output type to non-null.
- [filterOrdered()](/gatherers4j/gatherers/filtering-and-selection/filterordered/): Filter the input stream so that it contains `Comparable<INPUT>` elements in the order provided.
- [filterOrderedBy()](/gatherers4j/gatherers/filtering-and-selection/filterorderedby/): Filter the input stream so that it contains elements the order specified as measured by the given `Comparator`.
- [sampleFixedSize()](/gatherers4j/gatherers/filtering-and-selection/samplefixedsize/): Perform a fixed-size sampling over the input stream.
- [samplePercentage()](/gatherers4j/gatherers/filtering-and-selection/samplepercentage/): Perform a percentage-based sampling over the input stream.
- [takeEveryNth()](/gatherers4j/gatherers/filtering-and-selection/takeeverynth/): Take every `n`th element of the stream.
- [takeLast()](/gatherers4j/gatherers/filtering-and-selection/takelast/): Remove all but the last `count` elements from the stream.
- [takeUntil()](/gatherers4j/gatherers/filtering-and-selection/takeuntil/): Take elements from the input stream until the `predicate` is met, including the first element that matches the `predicate`.
- [uniquelyOccurring()](/gatherers4j/gatherers/filtering-and-selection/uniquelyoccurring/): Emit only those elements that occur in the input stream a single time.
- [uniquelyOccurringBy()](/gatherers4j/gatherers/filtering-and-selection/uniquelyoccurringby/): Emit only those elements that occur in the input stream a single time, as measured by the given function.
