public class Iterators2 extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Iterator<T> |
distinct(Iterator<T> iterator)
If we can assume the iterator is sorted, return the distinct elements.
|
static <T> Iterator<List<T>> |
groupBy(Iterator<? extends T> iterator,
Function<? super T,?> groupingFunction)
Divides an iterator into unmodifiable sublists of equivalent elements.
|
public static <T> Iterator<T> distinct(Iterator<T> iterator)
public static <T> Iterator<List<T>> groupBy(Iterator<? extends T> iterator, Function<? super T,?> groupingFunction)
[1, 3, 2, 4, 5] with a function grouping even and odd numbers
yields [[1, 3], [2, 4], [5] all in the original order.
The returned lists implement RandomAccess.
Copyright © 2018 Calrissian. All rights reserved.