gov.sandia.cognition.statistics.method
Class TreeSetBinner<ValueType extends Comparable<? super ValueType>>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.statistics.method.TreeSetBinner<ValueType>
Type Parameters:
ValueType - Value type to be binned; must be Comparable.
All Implemented Interfaces:
Binner<ValueType,ValueType>, CloneableSerializable, Serializable, Cloneable

@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 Comparable<? super ValueType>>
extends AbstractCloneableSerializable
implements Binner<ValueType,ValueType>

Implements a 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.2

Since:
2.0
Author:
zobenz
See Also:
Serialized Form

Constructor Summary
TreeSetBinner(Collection<? extends ValueType> binBoundaries)
          Creates a new TreeSetBinner using the provided List of bin boundaries.
 
Method Summary
 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.
 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
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeSetBinner

public TreeSetBinner(Collection<? extends ValueType> binBoundaries)
Creates a new TreeSetBinner using the provided List of bin boundaries.

Parameters:
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.
Method Detail

findBin

public ValueType findBin(ValueType value)
Description copied from interface: Binner
Finds the bin for the provided value, or null if a corresponding bin for the value does not exist.

Specified by:
findBin in interface Binner<ValueType extends Comparable<? super ValueType>,ValueType extends Comparable<? super ValueType>>
Parameters:
value - The value to get the bin for.
Returns:
The bin for the provided value, or null if a corresponding bin for the value does not exist

getBinCount

public int getBinCount()
Description copied from interface: Binner
Gets the total number of bins.

Specified by:
getBinCount in interface Binner<ValueType extends Comparable<? super ValueType>,ValueType extends Comparable<? super ValueType>>
Returns:
The total number of bins.

getBinSet

public TreeSet<ValueType> getBinSet()
Description copied from interface: Binner
Gets the set of bins that the binner is using.

Specified by:
getBinSet in interface Binner<ValueType extends Comparable<? super ValueType>,ValueType extends Comparable<? super ValueType>>
Returns:
The set of bins.

getMinValue

public ValueType getMinValue()
Gets the minimum value, inclusive, allowed in bins

Returns:
Minimum value, inclusive, allowed in bins

getMaxValue

public ValueType getMaxValue()
Gets the maximum value, exclusive, allowed in bins

Returns:
Maximum value, exclusive, allowed in bins