|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--quamj.qps.rm.RWHashtable
Hashtable using part of the name of the ResourceWrapper as keys, with no extra objects created. This uses the standard hash technique of adding a standard offset to the computed position in the table when a collision occurs, so that several checks may potentially be necessary in order to determine if a particular key value is present in the table (since if the slot calculated by the hash function is occupied by a different entry it's still necessary to check the offset slot for a match, and then the offset slot from that, until a empty slot is found).
Each time the number of entries present in the table grows above the specified fraction full the table is expanded to twice its prior size plus one (to ensure the size is always an odd number). The collision offset is set to half the table size rounded down, ensuring that it will cycle through all slots of the table before returning to the original slot.
Field Summary | |
protected static double |
DEFAULT_FILL
Default fill fraction allowed before growing table. |
protected int |
entryCount
Number of entries present in table. |
protected int |
entryLimit
Entries allowed before growing table. |
protected double |
fillFraction
Fill fraction allowed for this hash table. |
protected ResourceWrapper[] |
hashTable
Array of table slots. |
protected int |
hitOffset
Offset added (modulo table size) to slot number on collision. |
protected static int |
KEY_MULTIPLIER
Hash value multiplier to scramble bits before calculating slot. |
protected static int |
MINIMUM_SIZE
Minimum size used for hash table. |
Constructor Summary | |
RWHashtable()
Default constructor. |
|
RWHashtable(int count)
Constructor with only size supplied. |
|
RWHashtable(int count,
double fill)
Constructor with full specification. |
|
RWHashtable(ResourceWrapper[] from)
|
Method Summary | |
protected int |
assignSlot(ResourceWrapper entry)
Find slot number for entry. |
void |
clear()
Remove all entries from the table. |
protected void |
expandTable()
Expand the table. |
ResourceWrapper |
get(java.lang.String key)
Find an entry in the table. |
void |
put(ResourceWrapper entry)
Add an entry to the table. |
void |
remove(java.lang.String key)
Remove an entry from the table. |
int |
size()
Get number of items in table. |
ResourceWrapper[] |
toArray()
Construct an array containing all elements of the table. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final double DEFAULT_FILL
protected static final int MINIMUM_SIZE
protected static final int KEY_MULTIPLIER
protected double fillFraction
protected int entryCount
protected int entryLimit
protected int hitOffset
protected ResourceWrapper[] hashTable
Constructor Detail |
public RWHashtable(int count, double fill)
count
- number of values to assume in initial sizing of tablefill
- fraction full allowed for table before growingpublic RWHashtable(int count)
count
- number of values to assume in initial sizing of tablepublic RWHashtable()
public RWHashtable(ResourceWrapper[] from)
Method Detail |
public int size()
protected int assignSlot(ResourceWrapper entry)
entry
- entry to be added to table
protected void expandTable()
public void put(ResourceWrapper entry)
entry
- entry to be added to tablepublic ResourceWrapper get(java.lang.String key)
key
- for entry to be returned
null
if nonepublic void remove(java.lang.String key)
key
- for entry to be removedpublic void clear()
public ResourceWrapper[] toArray()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |