Class StatisticalRun<T>

  • Type Parameters:
    T - the type of object associated with the statistical run

    public class StatisticalRun<T>
    extends java.lang.Object
    A statistical run is a sequence of objects that are determined equal based on a comparator. A single item is a run of length 1. A set of items that are all the same are considered a single run. The set (0, 1, 1, 1, 0) has 3 runs.
    • Constructor Detail

      • StatisticalRun

        public StatisticalRun​(int startingIndex,
                              int endingIndex,
                              T startingObj,
                              T endingObj)
    • Method Detail

      • getStartingIndex

        public final int getStartingIndex()
        Returns:
        the starting index of the run
      • getEndingIndex

        public final int getEndingIndex()
        Returns:
        the ending index of the run
      • getLength

        public final int getLength()
        Returns:
        the length of the run, the number of consecutive items in the run
      • getStartingObject

        public final T getStartingObject()
        Returns:
        the object associated with the starting index
      • getEndingObject

        public final T getEndingObject()
        Returns:
        the object associated with the ending index
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • findRuns

        public static <T> java.util.List<StatisticalRun<T>> findRuns​(java.util.List<T> list,
                                                                     java.util.Comparator<T> comparator)
        Type Parameters:
        T - the type of objects being compared
        Parameters:
        list - A list holding a sequence of objects for comparison, must not be null
        comparator - a comparator to check for equality of the objects
        Returns:
        the List of the runs in the order that they were determined.
      • main

        public static void main​(java.lang.String[] args)