ValueType
- Value type to be binned; must be Comparable.@CodeReview(reviewer="Justin Basilico", date="2009-05-29", changesNeeded=false, comments={"Changed the implementation slightly to mach the interface.","Cleaned up the javadoc."}) public class TreeSetBinner<ValueType extends java.lang.Comparable<? super ValueType>> extends AbstractCloneableSerializable implements Binner<ValueType,ValueType>
Binner
that employs a TreeSet
to define the
boundaries of a contiguous set of bins. The user specified boundaries are
used to construct the bins, where bin membership is inclusive of the lower
bin bound and exclusive of the upper bin bound. Bins are labeled with their
lower bound value.
For example, if the bounds 1.5, 3.7, 4.2, and 10.9 are provided, then
three contiguous bins will be created:
[1.5, 3.7), with the label 1.5
[3.7, 4.2), with the label 3.7
[4.2, 10.9), with the label 4.2Constructor and Description |
---|
TreeSetBinner(java.util.Collection<? extends ValueType> binBoundaries)
Creates a new
TreeSetBinner using the provided List of
bin boundaries. |
Modifier and Type | Method and Description |
---|---|
ValueType |
findBin(ValueType value)
Finds the bin for the provided value, or null if a corresponding bin
for the value does not exist.
|
int |
getBinCount()
Gets the total number of bins.
|
java.util.TreeSet<ValueType> |
getBinSet()
Gets the set of bins that the binner is using.
|
ValueType |
getMaxValue()
Gets the maximum value, exclusive, allowed in bins
|
ValueType |
getMinValue()
Gets the minimum value, inclusive, allowed in bins
|
clone
public TreeSetBinner(java.util.Collection<? extends ValueType> binBoundaries)
TreeSetBinner
using the provided List of
bin boundaries.binBoundaries
- A List of values to be used as boundary cutoffs for bins; bin
membership is inclusive of the lower bin bound and exclusive of
the upper bin bound.public ValueType findBin(ValueType value)
Binner
findBin
in interface Binner<ValueType extends java.lang.Comparable<? super ValueType>,ValueType extends java.lang.Comparable<? super ValueType>>
value
- The value to get the bin for.public int getBinCount()
Binner
public java.util.TreeSet<ValueType> getBinSet()
Binner
public ValueType getMinValue()
public ValueType getMaxValue()