Package jsl.utilities.statistic
Class StatisticalRun<T>
- java.lang.Object
-
- jsl.utilities.statistic.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 Summary
Constructors Constructor Description StatisticalRun(int startingIndex, int endingIndex, T startingObj, T endingObj)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> java.util.List<StatisticalRun<T>>
findRuns(java.util.List<T> list, java.util.Comparator<T> comparator)
int
getEndingIndex()
T
getEndingObject()
int
getLength()
int
getStartingIndex()
T
getStartingObject()
static void
main(java.lang.String[] args)
java.lang.String
toString()
-
-
-
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 classjava.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 nullcomparator
- 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)
-
-