|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object
|
+--com.sosnoski.util.PrimitiveHashBase
|
+--com.sosnoski.util.hashmap.PrimitiveKeyBase
|
+--com.sosnoski.util.hashmap.IntStringHashMap
Hash map using primitive int values as keys mapped to
String values. This implementation is unsynchronized in order
to provide the best possible performance for typical usage scenarios, so
explicit synchronization must be implemented by a wrapper class or directly
by the application in cases where instances are modified in a multithreaded
environment. See the base classes for other details of the
hash map implementation.
| Field Summary | |
protected int[] |
m_keyTable
Array of key table slots. |
protected java.lang.String[] |
m_valueTable
Array of value table slots. |
| Fields inherited from class com.sosnoski.util.PrimitiveHashBase |
DEFAULT_FILL, KEY_MULTIPLIER, m_entryCount, m_entryLimit, m_fillFraction, m_flagTable, m_hitOffset, MINIMUM_SIZE |
| Constructor Summary | |
IntStringHashMap()
Default constructor. |
|
IntStringHashMap(int count)
Constructor with only size supplied. |
|
IntStringHashMap(int count,
double fill)
Constructor with full specification. |
|
IntStringHashMap(IntStringHashMap base)
Copy (clone) constructor. |
|
| Method Summary | |
java.lang.String |
add(int key,
java.lang.String value)
Add an entry to the table. |
protected int |
assignSlot(int key,
java.lang.String value)
Assign slot for entry. |
java.lang.Object |
clone()
Construct a copy of the table. |
protected int |
computeSlot(int key)
Compute the base slot for a key. |
boolean |
containsKey(int key)
Check if an entry is present in the table. |
java.lang.String |
get(int key)
Find an entry in the table. |
protected java.lang.Object |
getKeyArray()
Get the backing array of keys. |
protected java.lang.Object |
getValueArray()
Get the backing array of values. |
protected int |
internalFind(int key)
Internal find key in table. |
protected boolean |
reinsert(int slot)
Reinsert an entry into the hash map. |
java.lang.String |
remove(int key)
Remove an entry from the table. |
protected void |
restructure(boolean[] flags,
java.lang.Object karray,
java.lang.Object varray)
Restructure the table. |
protected void |
setKeyArray(java.lang.Object array)
Set the backing array of keys. |
protected void |
setValueArray(java.lang.Object array)
Set the backing array of values. |
java.util.Iterator |
valueIterator()
Return an iterator for the value Objects in this map. |
| Methods inherited from class com.sosnoski.util.hashmap.PrimitiveKeyBase |
clear, reallocate |
| Methods inherited from class com.sosnoski.util.PrimitiveHashBase |
ensureCapacity, freeSlot, growCapacity, size, stepSlot |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int[] m_keyTable
protected java.lang.String[] m_valueTable
| Constructor Detail |
public IntStringHashMap(int count,
double fill)
count - number of values to assume in initial sizing of tablefill - fraction full allowed for table before growingpublic IntStringHashMap(int count)
count - number of values to assume in initial sizing of tablepublic IntStringHashMap()
public IntStringHashMap(IntStringHashMap base)
base - instance being copied| Method Detail |
protected final java.lang.Object getKeyArray()
getKeyArray in class PrimitiveHashBaseprotected final void setKeyArray(java.lang.Object array)
setKeyArray in class PrimitiveHashBasearray - backing key array objectprotected final java.lang.Object getValueArray()
getValueArray in class PrimitiveKeyBaseprotected final void setValueArray(java.lang.Object array)
setValueArray in class PrimitiveKeyBasearray - backing value array objectprotected final boolean reinsert(int slot)
slot - position of entry to be reinserted into hash maptrue if the slot number used by the entry has
has changed, false if not
protected void restructure(boolean[] flags,
java.lang.Object karray,
java.lang.Object varray)
restructure in class PrimitiveKeyBaseflags - array of flags for array slots usedkarray - array of keysvarray - array of valuesprotected final int computeSlot(int key)
key - key value to be computed
protected int assignSlot(int key,
java.lang.String value)
key - key to be added to tablevalue - associated value for key
public java.lang.String add(int key,
java.lang.String value)
key - key to be added to tablevalue - associated value for keynull if
key not previously present in tableprotected final int internalFind(int key)
key - to be found in table-index-1 of slot to be
used for inserting key in table if not already present (always negative)public final boolean containsKey(int key)
null values in the table.key - key for entry to be foundtrue if key found in table, false
if notpublic final java.lang.String get(int key)
key - key for entry to be returnednull if key not foundpublic java.lang.String remove(int key)
key - key to be removed from tablenull if key
not found in tablepublic final java.util.Iterator valueIterator()
Objects in this map. The
iterator returns all values in arbitrary order, but is not "live". Any
changes to the map while the iteration is in progress will give
indeterminant results.public java.lang.Object clone()
clone in class java.lang.Object
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||