public final class IntTable<E> extends Object implements Iterable<IntTable.Entry<E>>, Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
IntTable.Entry<E>
encapsulates an Entry in the table.
|
static class |
IntTable.Snapshot<E>
helper class to store a compact, invariant representation of this table
|
protected class |
IntTable.TblIterator |
Modifier and Type | Field and Description |
---|---|
protected int |
mask |
protected int |
nextRehash |
protected IntTable.Entry<E> |
nullEntry |
protected int |
size |
protected IntTable.Entry<E>[] |
table |
protected int |
tblPow |
Modifier and Type | Method and Description |
---|---|
IntTable.Entry<E> |
add(E key,
int val)
ONLY USE IF YOU ARE SURE NO PREVIOUS BINDING FOR key EXISTS.
|
protected void |
addEntry(IntTable.Entry<E> e,
int idx) |
void |
clear()
empties the table, leaving it capacity the same.
|
IntTable<E> |
clone() |
int |
computeSize() |
void |
dump()
for debugging purposes
|
IntTable.Entry<E> |
get(E key)
lookup, returning null if no binding.
|
protected IntTable.Entry<E> |
getEntry(E key,
int idx) |
IntTable.Entry<E> |
getInc(E key)
a little optimization to speed up counter increments
|
IntTable.Snapshot<E> |
getSnapshot() |
protected int |
getTableIndex(E key) |
boolean |
hasEntry(E key)
shorthand for
get(key) != null . |
Iterator<IntTable.Entry<E>> |
iterator()
returns an iterator over the entries.
|
protected boolean |
maybeRehash() |
protected void |
newTable(int pow) |
int |
nextPoolVal()
returns the next val to be assigned by a call to pool() on a fresh key.
|
IntTable.Entry<E> |
pool(E key)
gets the Entry associated with key, adding previous `size' if not yet bound.
|
int |
poolIndex(E key)
shorthand for
pool(key).val . |
E |
poolKey(E key)
shorthand for
pool(key).key . |
void |
put(E key,
int val)
just like HashMap put.
|
IntTable.Entry<E> |
remove(E key)
removes a binding/entry from the table.
|
protected void |
replaceEntryValue(int idx,
IntTable.Entry<E> oldEntry,
int newValue) |
void |
restore(IntTable.Snapshot<E> snapshot) |
int |
size()
returns number of bindings in the table.
|
protected IntTable.Entry<E>[] table
protected int tblPow
protected int mask
protected int nextRehash
protected int size
protected IntTable.Entry<E> nullEntry
public IntTable.Snapshot<E> getSnapshot()
public void restore(IntTable.Snapshot<E> snapshot)
protected void newTable(int pow)
protected int getTableIndex(E key)
protected boolean maybeRehash()
protected void addEntry(IntTable.Entry<E> e, int idx)
protected IntTable.Entry<E> getEntry(E key, int idx)
protected void replaceEntryValue(int idx, IntTable.Entry<E> oldEntry, int newValue)
public int size()
public IntTable.Entry<E> add(E key, int val)
public IntTable.Entry<E> get(E key)
public IntTable.Entry<E> getInc(E key)
public void put(E key, int val)
public IntTable.Entry<E> remove(E key)
public void clear()
public int nextPoolVal()
public IntTable.Entry<E> pool(E key)
public int poolIndex(E key)
pool(key).val
.public boolean hasEntry(E key)
get(key) != null
.public Iterator<IntTable.Entry<E>> iterator()
iterator
in interface Iterable<IntTable.Entry<E>>
public void dump()
public int computeSize()