Class Clustered<T>

java.lang.Object
org.dmfs.jems2.iterable.Clustered<T>
All Implemented Interfaces:
Iterable<Iterable<T>>

public final class Clustered<T> extends Object implements Iterable<Iterable<T>>
An 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]
 ]