Skip to content

Commit

Permalink
docs: update distinct in guide
Browse files Browse the repository at this point in the history
  • Loading branch information
julianhowarth committed Nov 4, 2024
1 parent 2b52fef commit be44288
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ If you have a stream emitting the `{1, 1, 2, 3, 4, 5, 5, 6, 1, 4, 4}` items, the
By default, `select().distinct()` uses the `hashCode` method from the item's class.
You can pass a custom comparator for more advanced checks.

If you have a stream emitting items of type `T`, where duplicates can be identified through an attribute of `T` of type `K`,
then an `extractor` of type `Function<T, K>` can be defined. Applying `.select().distinct(extractor)` on such a stream will
eliminate duplicates but have a lesser memory overhead as only the references to the extracted keys need to be kept, not the whole object.
A typical usage of this might be for a stream of records where uniqueness is determined by a UUID assigned to every record.

## Skipping repetitions

The `.skip().repetitions()` operator removes subsequent repetitions of an item:
Expand Down

0 comments on commit be44288

Please sign in to comment.