|
||||||
| 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.hashset.PrimitiveSetBase
|
+--com.sosnoski.util.hashset.DoubleHashSet
Hash set using primitive double 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 set implementation.
Note that the hashing function implemented in this class has not been tested
extensively and may be unsuitable for use with some patterns of data values.
To change the hashing function, modify the computeSlot()
method.
| Field Summary | |
protected double[] |
m_keyTable
Array of key 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 | |
DoubleHashSet()
Default constructor. |
|
DoubleHashSet(DoubleHashSet base)
Copy (clone) constructor. |
|
DoubleHashSet(int count)
Constructor with only size supplied. |
|
DoubleHashSet(int count,
double fill)
Constructor with full specification. |
|
| Method Summary | |
boolean |
add(double key)
Add a key to the table. |
protected int |
assignSlot(double key)
Assign slot for key. |
java.lang.Object |
clone()
Construct a copy of the table. |
protected int |
computeSlot(double key)
Compute the base slot for a key. |
boolean |
contains(double key)
Check if a key is present in the set. |
protected java.lang.Object |
getKeyArray()
Get the backing array of keys. |
protected int |
internalFind(double key)
Internal find key in table. |
protected boolean |
reinsert(int slot)
Reinsert a key into the hash set. |
boolean |
remove(double key)
Remove a key from the table. |
protected void |
restructure(boolean[] flags,
java.lang.Object karray)
Restructure the table. |
protected void |
setKeyArray(java.lang.Object array)
Set the backing array of keys. |
| Methods inherited from class com.sosnoski.util.hashset.PrimitiveSetBase |
reallocate |
| Methods inherited from class com.sosnoski.util.PrimitiveHashBase |
clear, 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 double[] m_keyTable
| Constructor Detail |
public DoubleHashSet(int count,
double fill)
count - number of values to assume in initial sizing of tablefill - fraction full allowed for table before growingpublic DoubleHashSet(int count)
count - number of values to assume in initial sizing of tablepublic DoubleHashSet()
public DoubleHashSet(DoubleHashSet base)
base - instance being copied| Method Detail |
protected java.lang.Object getKeyArray()
getKeyArray in class PrimitiveHashBaseprotected void setKeyArray(java.lang.Object array)
setKeyArray in class PrimitiveHashBasearray - backing key array objectprotected final boolean reinsert(int slot)
slot - position of key to be reinserted into hash settrue if the slot number used by the key has
has changed, false if not
protected void restructure(boolean[] flags,
java.lang.Object karray)
restructure in class PrimitiveSetBaseflags - array of flags for array slots usedkarray - array of keysprotected final int computeSlot(double key)
key - key value to be computedprotected int assignSlot(double key)
key - key to be added to tablepublic boolean add(double key)
key - key to be added to tabletrue if key added to set, false if
already present in setprotected final int internalFind(double 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 boolean contains(double key)
key - key to be foundtrue if key found in table, false
if notpublic boolean remove(double key)
key - key to be removed from tabletrue if key successfully removed from set,
false if key not found in setpublic 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 | |||||