
T - Histogram data type.public class ReplacingHistogram<T> extends Object implements Iterable<DoubleObjPair<T>>
| Modifier and Type | Class and Description |
|---|---|
static class |
ReplacingHistogram.Adapter<T>
Interface to plug in a data type T.
|
protected class |
ReplacingHistogram.Iter
Iterator class to iterate over all bins.
|
protected class |
ReplacingHistogram.RIter
Iterator class to iterate over all bins.
|
| Modifier and Type | Field and Description |
|---|---|
protected double |
base
Array 'base', i.e. the point of 0.0.
|
protected double |
binsize
Width of a bin.
|
protected ArrayList<T> |
data
Data storage
|
private ReplacingHistogram.Adapter<T> |
maker
Constructor for new elements
|
protected double |
max
To avoid introducing an extra bucket for the maximum value.
|
protected int |
offset
Array shift to account for negative indices.
|
protected int |
size
Size of array storage.
|
| Constructor and Description |
|---|
ReplacingHistogram(int bins,
double min,
double max)
Histogram constructor without 'Constructor' to generate new elements.
|
ReplacingHistogram(int bins,
double min,
double max,
ReplacingHistogram.Adapter<T> maker)
Histogram constructor
|
| Modifier and Type | Method and Description |
|---|---|
static ReplacingHistogram<DoubleDoublePair> |
DoubleDoubleHistogram(int bins,
double min,
double max)
Convenience constructor for Histograms with pairs of Doubles Uses a
constructor to initialize bins with Pair(Double(0),Double(0))
|
static ReplacingHistogram<Double> |
DoubleHistogram(int bins,
double min,
double max)
Convenience constructor for Double-based Histograms.
|
T |
get(double coord)
Get the data at a given Coordinate.
|
double |
getBinMax(int bin)
Maximum of bin
|
double |
getBinMean(int bin)
Mean of bin
|
double |
getBinMin(int bin)
Minimum of bin
|
protected int |
getBinNr(double coord)
Compute the bin number.
|
double |
getBinsize()
Get the size (width) of a bin.
|
double |
getCoverMaximum()
Get maximum (covered by bins, not data!)
|
double |
getCoverMinimum()
Get minimum (covered by bins, not data!)
|
ArrayList<T> |
getData()
Get the raw data.
|
int |
getNumBins()
Get the number of bins actually in use.
|
static ReplacingHistogram<Integer> |
IntHistogram(int bins,
double min,
double max)
Convenience constructor for Integer-based Histograms.
|
static ReplacingHistogram<IntIntPair> |
IntIntHistogram(int bins,
double min,
double max)
Convenience constructor for Histograms with pairs of Integers Uses a
constructor to initialize bins with Pair(Integer(0),Integer(0))
|
Iterator<DoubleObjPair<T>> |
iterator()
Get an iterator over all histogram bins.
|
protected T |
make()
Make a new bin.
|
private void |
putBin(int bin,
T d)
Internal put function to handle the special cases of histogram resizing.
|
void |
replace(double coord,
T d)
Put data at a given coordinate.
|
Iterator<DoubleObjPair<T>> |
reverseIterator()
Get an iterator over all histogram bins.
|
protected int offset
protected int size
protected double base
protected double max
protected double binsize
private ReplacingHistogram.Adapter<T> maker
public ReplacingHistogram(int bins,
double min,
double max,
ReplacingHistogram.Adapter<T> maker)
bins - Number of bins to use.min - Minimum Valuemax - Maximum Valuemaker - Constructor for new elements.public ReplacingHistogram(int bins,
double min,
double max)
bins - Number of binsmin - Minimum valuemax - Maximum value.public T get(double coord)
coord - Coordinate.public void replace(double coord,
T d)
coord - Coordinated - New Dataprotected int getBinNr(double coord)
coord - Coordinateprivate void putBin(int bin,
T d)
bin - bin numberd - data to putpublic int getNumBins()
public double getBinsize()
public double getBinMean(int bin)
bin - Bin numberpublic double getBinMin(int bin)
bin - Bin numberpublic double getBinMax(int bin)
bin - Bin numberpublic double getCoverMinimum()
public double getCoverMaximum()
public ArrayList<T> getData()
protected T make()
public Iterator<DoubleObjPair<T>> iterator()
iterator in interface Iterable<DoubleObjPair<T>>public Iterator<DoubleObjPair<T>> reverseIterator()
public static ReplacingHistogram<Integer> IntHistogram(int bins, double min, double max)
bins - Number of binsmin - Minimum coordinatemax - Maximum coordinatepublic static ReplacingHistogram<Double> DoubleHistogram(int bins, double min, double max)
bins - Number of binsmin - Minimum coordinatemax - Maximum coordinatepublic static ReplacingHistogram<IntIntPair> IntIntHistogram(int bins, double min, double max)
bins - Number of binsmin - Minimum coordinatemax - Maximum coordinatepublic static ReplacingHistogram<DoubleDoublePair> DoubleDoubleHistogram(int bins, double min, double max)
bins - Number of binsmin - Minimum coordinatemax - Maximum coordinate