public class FloatDict
extends java.lang.Object
IntDict
,
StringDict
Modifier and Type | Class and Description |
---|---|
class |
FloatDict.Entry |
Constructor and Description |
---|
FloatDict() |
FloatDict(java.io.BufferedReader reader)
Read a set of entries from a Reader that has each key/value pair on
a single line, separated by a tab.
|
FloatDict(int length)
Create a new lookup with a specific size.
|
FloatDict(java.lang.Object[][] pairs)
Constructor to allow (more intuitive) inline initialization, e.g.:
|
FloatDict(java.lang.String[] keys,
float[] values) |
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String key,
float amount) |
void |
clear()
Remove all entries.
|
FloatDict |
copy()
Returns a duplicate copy of this object.
|
void |
div(java.lang.String key,
float amount) |
java.lang.Iterable<FloatDict.Entry> |
entries() |
java.util.Iterator<FloatDict.Entry> |
entryIterator() |
float |
get(java.lang.String key)
Return a value for the specified key.
|
float |
get(java.lang.String key,
float alternate) |
FloatDict |
getPercent()
Sum all of the values in this dictionary, then return a new FloatDict of
each key, divided by the total sum.
|
boolean |
hasKey(java.lang.String key) |
int |
index(java.lang.String what) |
java.lang.String |
key(int index) |
java.lang.String[] |
keyArray()
Return a copy of the internal keys array.
|
java.lang.String[] |
keyArray(java.lang.String[] outgoing) |
java.util.Iterator<java.lang.String> |
keyIterator() |
java.lang.Iterable<java.lang.String> |
keys() |
int |
maxIndex() |
java.lang.String |
maxKey()
The key for a max value; null if empty or everything is NaN (no max).
|
float |
maxValue()
The max value.
|
int |
minIndex() |
java.lang.String |
minKey() |
float |
minValue() |
void |
mult(java.lang.String key,
float amount) |
void |
print() |
float |
remove(java.lang.String key) |
float |
removeIndex(int index) |
void |
resize(int length)
Resize the internal data, this can only be used to shrink the list.
|
void |
save(java.io.File file)
Save tab-delimited entries to a file (TSV format, UTF-8 encoding)
|
void |
set(java.lang.String key,
float amount) |
void |
setIndex(int index,
java.lang.String key,
float value) |
int |
size() |
void |
sortKeys()
Sort the keys alphabetically (ignoring case).
|
void |
sortKeysReverse() |
void |
sortValues()
Sort by values in descending order (largest value will be at [0]).
|
void |
sortValues(boolean stable)
Set true to ensure that the order returned is identical.
|
void |
sortValuesReverse() |
void |
sortValuesReverse(boolean stable) |
void |
sub(java.lang.String key,
float amount) |
float |
sum() |
double |
sumDouble() |
void |
swap(int a,
int b) |
java.lang.String |
toJSON()
Return this dictionary as a String in JSON format.
|
java.lang.String |
toString() |
float |
value(int index) |
float[] |
valueArray()
Create a new array and copy each of the values into it.
|
float[] |
valueArray(float[] array)
Fill an already-allocated array with the values (more efficient than
creating a new array each time).
|
java.util.Iterator<java.lang.Float> |
valueIterator() |
java.lang.Iterable<java.lang.Float> |
values() |
void |
write(java.io.PrintWriter writer)
Write tab-delimited entries out to
|
public FloatDict()
public FloatDict(int length)
public FloatDict(java.io.BufferedReader reader)
public FloatDict(java.lang.String[] keys, float[] values)
public FloatDict(java.lang.Object[][] pairs)
new FloatDict(new Object[][] { { "key1", 1 }, { "key2", 2 } });
public int size()
public void resize(int length)
public void clear()
public java.lang.Iterable<FloatDict.Entry> entries()
public java.util.Iterator<FloatDict.Entry> entryIterator()
public java.lang.String key(int index)
public java.lang.Iterable<java.lang.String> keys()
public java.util.Iterator<java.lang.String> keyIterator()
public java.lang.String[] keyArray()
public java.lang.String[] keyArray(java.lang.String[] outgoing)
public float value(int index)
public java.lang.Iterable<java.lang.Float> values()
public java.util.Iterator<java.lang.Float> valueIterator()
public float[] valueArray()
public float[] valueArray(float[] array)
public float get(java.lang.String key)
public float get(java.lang.String key, float alternate)
public void set(java.lang.String key, float amount)
public void setIndex(int index, java.lang.String key, float value)
public boolean hasKey(java.lang.String key)
public void add(java.lang.String key, float amount)
public void sub(java.lang.String key, float amount)
public void mult(java.lang.String key, float amount)
public void div(java.lang.String key, float amount)
public int minIndex()
public java.lang.String minKey()
public float minValue()
public int maxIndex()
public java.lang.String maxKey()
public float maxValue()
public float sum()
public double sumDouble()
public int index(java.lang.String what)
public float remove(java.lang.String key)
public float removeIndex(int index)
public void swap(int a, int b)
public void sortKeys()
public void sortKeysReverse()
public void sortValues()
public void sortValues(boolean stable)
stable
- public void sortValuesReverse()
public void sortValuesReverse(boolean stable)
public FloatDict getPercent()
public FloatDict copy()
public void print()
public void save(java.io.File file)
public void write(java.io.PrintWriter writer)
writer
- public java.lang.String toJSON()
public java.lang.String toString()
toString
in class java.lang.Object