public class TIntMap<T extends java.lang.Comparable> extends AbstractTMap<T> implements java.lang.Iterable<TIntMap.Entry>, java.io.Serializable
Note: in the sorted list, we first sort the keys by hash code, and then for equal hash code, we sort by the objects values. We hope that hash code collisions will be rare enough that we won't have to resort to comparing objects.
Typical usage: - Construct a map using a hash table. - To save space, switch to a sorted list representation.
Will get runtime exception if try to used sorted list and keys are not comparable.
Modifier and Type | Class and Description |
---|---|
class |
TIntMap.Entry |
class |
TIntMap.EntrySet |
class |
TIntMap.EntryValueComparator |
class |
TIntMap.KeySet |
class |
TIntMap.ValueCollection |
AbstractTMap.Functionality<T extends java.lang.Comparable>, AbstractTMap.MapType
Modifier and Type | Field and Description |
---|---|
protected static long |
serialVersionUID |
defaultExpectedSize, growFactor, keyFunc, keys, loadFactor, locked, mapType, num, numCollisions
Constructor and Description |
---|
TIntMap() |
TIntMap(AbstractTMap.Functionality<T> keyFunc) |
TIntMap(AbstractTMap.Functionality<T> keyFunc,
int expectedSize)
expectedSize: expected number of entries we're going to have in the map.
|
TIntMap(AbstractTMap<T> map) |
TIntMap(int expectedSize) |
Modifier and Type | Method and Description |
---|---|
T |
argmax() |
int |
capacity() |
boolean |
containsKey(T key) |
TIntMap<T> |
copy() |
TIntMap.EntrySet |
entrySet() |
TIntMap.EntryValueComparator |
entryValueComparator() |
int |
get(T key,
int defaultValue) |
int |
getSure(T key) |
void |
gut() |
void |
incr(T key,
int dValue) |
void |
incrAll(int dValue) |
void |
incrIfKeyExists(T key,
int dValue) |
void |
incrMap(TIntMap<T> map,
int factor) |
edu.berkeley.nlp.lm.collections.TIntMap.EntryIterator |
iterator() |
TIntMap.KeySet |
keySet() |
void |
lock() |
double |
max() |
void |
multAll(int dValue) |
void |
put(T key,
int value) |
void |
put(T key,
int value,
boolean keepHigher) |
void |
putAll(int value) |
TIntMap<T> |
restrict(java.util.Set<T> set) |
void |
scale(T key,
int dValue) |
int |
size() |
double |
sum() |
void |
switchToHashTable() |
void |
switchToSortedList() |
java.lang.String |
toString() |
TIntMap.ValueCollection |
values() |
defaultFunctionality
protected static final long serialVersionUID
public TIntMap()
public TIntMap(AbstractTMap.Functionality<T> keyFunc)
public TIntMap(int expectedSize)
public TIntMap(AbstractTMap<T> map)
public TIntMap(AbstractTMap.Functionality<T> keyFunc, int expectedSize)
public boolean containsKey(T key)
public int get(T key, int defaultValue)
public int getSure(T key)
public void put(T key, int value)
public void put(T key, int value, boolean keepHigher)
public void incr(T key, int dValue)
public void incrIfKeyExists(T key, int dValue)
public void scale(T key, int dValue)
public int size()
public int capacity()
public void gut()
public double sum()
public void putAll(int value)
public void incrAll(int dValue)
public void multAll(int dValue)
public T argmax()
public double max()
public TIntMap.EntryValueComparator entryValueComparator()
public void lock()
public void switchToSortedList()
public void switchToHashTable()
public edu.berkeley.nlp.lm.collections.TIntMap.EntryIterator iterator()
iterator
in interface java.lang.Iterable<TIntMap.Entry>
public TIntMap.EntrySet entrySet()
public TIntMap.KeySet keySet()
public TIntMap.ValueCollection values()
public java.lang.String toString()
toString
in class java.lang.Object