public class Histogram
extends java.lang.Object
Constructor and Description |
---|
Histogram()
Creates an instance with an initial size of 10
|
Histogram(int initialSize)
The constructor of Histogram.
|
Histogram(java.lang.String csv,
java.lang.String separator)
Creates a Histogram and uses the CSV string as preface.
|
Modifier and Type | Method and Description |
---|---|
void |
createFromString(java.lang.String string,
java.lang.String separator)
Converts the given CSV-string into a histogram.
|
float |
getFirstValueIndex()
Returns the smallest index that contains a non-zero value
|
int |
getFirstValueIndexUnscaled()
Returns the smallest index that contains a non-zero value without taking the x-scale into account
|
java.lang.String |
getKeyHeading()
Returns the key heading of the CSV output.
|
int |
getMaxIndex()
Returns the largest index with an explicit value.
|
float |
getMaxValue()
Returns the maximum value of all entries.
|
float |
getValue(float index)
Returns the value at the given index.
|
int |
getValueCount()
Returns the current amount of allocated values.
|
java.lang.String |
getValueHeading()
Returns the value heading of the CSV output.
|
float |
getValueUnscaled(int index)
Same as getValue, but does not multiply the given index with the x-scale factor.
|
int |
getXScale() |
void |
incValue(float index)
Increments the value at the given index by 1.
|
void |
incValue(float index,
java.lang.Float value)
Increments the value at the given index by the given value.
|
void |
setCsvValueListMode(boolean csvValueListMode)
Specifies whether the toString method shall return the string representation as a CSV string or as a simple
list without indices.
|
void |
setDefaultSeparator(java.lang.String separator)
Sets the default key-value-separator for CSV output.
|
void |
setHeadingLine(java.lang.String keyHeading,
java.lang.String valueHeading)
Sets the first line of the CSV output.
|
void |
setIntOutput()
After calling this method, the CSV output will output the values without fractional digits.
|
void |
setValue(float index,
java.lang.Float value)
Sets the value at the given index.
|
Histogram |
setXScale(int scale)
Sets the x-scale.
|
java.lang.String |
toCSV()
Returns the histogram in its CSV representation with the default separator.
|
java.lang.String |
toCSV(java.lang.String separator)
Returns the histogram in its CSV representation.
|
java.lang.String |
toString() |
public Histogram(java.lang.String csv, java.lang.String separator) throws java.lang.NumberFormatException
csv
- A string which contains integral numbers in the first column and float numbers as the secondseparator
- the separator of a key-value-pair.java.lang.NumberFormatException
public Histogram(int initialSize)
initialSize
- Determines the initial number of allocated indices. However, this is not the capacity. New
indices are allocated automatically if it is necessary.public Histogram()
public void setHeadingLine(java.lang.String keyHeading, java.lang.String valueHeading)
keyHeading
- the first column of the heading.valueHeading
- the second column of the heading.public void setIntOutput()
public void setDefaultSeparator(java.lang.String separator)
public java.lang.String getKeyHeading()
public java.lang.String getValueHeading()
public void setCsvValueListMode(boolean csvValueListMode)
csvValueListMode
- The value list modepublic int getValueCount()
public float getValue(float index)
index
- The index to readpublic float getValueUnscaled(int index)
public void setValue(float index, java.lang.Float value)
index
- The index of the entry which shall be setvalue
- The new valuepublic void incValue(float index, java.lang.Float value)
index
- The index of the entry which shall be setvalue
- The value which shall be added (may be negative, too).public void incValue(float index)
index
- The index of the entry of which the value is supposed to be incrementedpublic java.lang.String toCSV(java.lang.String separator)
public java.lang.String toCSV()
public java.lang.String toString()
toString
in class java.lang.Object
public void createFromString(java.lang.String string, java.lang.String separator) throws java.lang.NumberFormatException
string
- a string which contains integral numbers in the first column and float numbers as the second.separator
- the separator for a key-value-pair.java.lang.NumberFormatException
public float getMaxValue()
public int getMaxIndex()
public float getFirstValueIndex()
public int getXScale()
public Histogram setXScale(int scale)
public int getFirstValueIndexUnscaled()