Class Grouper<ElementType>


  • public class Grouper<ElementType>
    extends java.lang.Object
    Given a sorted Collection and a Comparator, produces groups of objects that compare as equal. If the Collection is not sorted, this class will not work correctly.
    Author:
    David Hovemeyer
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void group​(java.util.Collection<ElementType> collection, java.util.Comparator<ElementType> comparator)
      Group elements of given collection according to given compartor's test for equality.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Grouper

        public Grouper​(Grouper.Callback<ElementType> callback)
        Creates a new instance of Grouper.
        Parameters:
        callback - the callback which receives the groups and elements
    • Method Detail

      • group

        public void group​(java.util.Collection<ElementType> collection,
                          java.util.Comparator<ElementType> comparator)
        Group elements of given collection according to given compartor's test for equality. The groups are specified by calls to the Grouper's callback object.
        Parameters:
        collection - the collection
        comparator - the comparator