Skip to content

Commit e61d8d3

Browse files
committed
Add documentation for FilterUnique
1 parent 480f731 commit e61d8d3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,23 @@ values, err := it.TryCollect(itx.FromSlice([]int{"foo", "bar"}).FilterError(isFo
591591
values, err := it.TryCollect(itx.FromSlice([]int{"foo", "bar"}).ExcludeError(isFoo))
592592
```
593593

594+
### FilterUnique
595+
596+
FilterUnique yields only the unique values from an iterator.
597+
598+
```go
599+
values := it.FilterUnique(slices.Values([]int{1, 2, 2, 3, 3, 3, 4}))
600+
```
601+
602+
<!-- prettier-ignore -->
603+
> [!WARNING]
604+
> Unique values are stored in memory until the iterator is exhausted. Large iterators with
605+
> many unique values may use a large amount of memory.
606+
607+
<!-- prettier-ignore -->
608+
> [!NOTE]
609+
> The `itx` package does not contain `FilterUnique` due to limitations with Go's type system.
610+
594611
### Integers
595612

596613
Integers yields all integers in the range [start, stop) with the given step.

0 commit comments

Comments
 (0)