public final class Clustered<T>
extends java.lang.Object
implements java.lang.Iterable<java.lang.Iterable<T>>
Iterable decorator which clusters consecutive elements of another Iterable by the result of a Comparator. Consecutive elements
which compare to 0 go into the same cluster. The original order of the elements remains the same.
Clustered(Comparator.naturalOrder(), [5, 5, 5, 3, 3, 4, 4, 4, 5, 5, 2, 2]) ->
[
[5, 5, 5],
[3, 3],
[4, 4, 4],
[5, 5],
[2, 2]
]
| Constructor and Description |
|---|
Clustered(java.util.Comparator<? super T> comparator,
java.lang.Iterable<T> delegate) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Iterator<java.lang.Iterable<T>> |
iterator() |