Class Clustered<T>

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.Iterable<T>>

    public final class Clustered<T>
    extends BaseIterator<java.lang.Iterable<T>>
    An Iterator decorator which clusters consecutive elements of another Iterator 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 Summary

      Constructors 
      Constructor Description
      Clustered​(java.util.Comparator<? super T> comparator, java.util.Iterator<T> delegate)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      java.lang.Iterable<T> next()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • Clustered

        public Clustered​(java.util.Comparator<? super T> comparator,
                         java.util.Iterator<T> delegate)
    • Method Detail

      • hasNext

        public boolean hasNext()
      • next

        public java.lang.Iterable<T> next()