public class SymbolHash extends Object
The hash code uses the same algorithm as SymbolTable class.
Modifier and Type | Class and Description |
---|---|
protected static class |
SymbolHash.Entry
This class is a key table entry.
|
Modifier and Type | Field and Description |
---|---|
protected SymbolHash.Entry[] |
fBuckets
Buckets.
|
protected int[] |
fHashMultipliers
Array of randomly selected hash function multipliers or
null
if the default String.hashCode() function should be used. |
protected int |
fNum
Number of elements.
|
protected int |
fTableSize
Actual table size
|
protected static int |
MAX_HASH_COLLISIONS
Maximum hash collisions per bucket.
|
protected static int |
MULTIPLIERS_MASK |
protected static int |
MULTIPLIERS_SIZE |
protected static int |
TABLE_SIZE
Default table size.
|
Constructor and Description |
---|
SymbolHash()
Constructs a key table with the default size.
|
SymbolHash(int size)
Constructs a key table with a given size.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all key/value association.
|
Object |
get(Object key)
Get the value associated with the given key.
|
Object[] |
getEntries()
Return key/value pairs of all entries in the map
|
int |
getLength()
Get the number of key/value pairs stored in this table.
|
int |
getValues(Object[] elements,
int from)
Add all values to the given array.
|
protected int |
hash(Object key)
Returns a hashcode value for the specified key.
|
SymbolHash |
makeClone()
Make a clone of this object.
|
void |
put(Object key,
Object value)
Adds the key/value mapping to the key table.
|
protected void |
rebalance()
Randomly selects a new hash function and reorganizes this SymbolHash
in order to more evenly distribute its entries across the table.
|
protected void |
rehash()
Increases the capacity of and internally reorganizes this
SymbolHash, in order to accommodate and access its entries more
efficiently.
|
protected SymbolHash.Entry |
search(Object key,
int bucket) |
protected static final int TABLE_SIZE
protected static final int MAX_HASH_COLLISIONS
protected static final int MULTIPLIERS_SIZE
protected static final int MULTIPLIERS_MASK
protected int fTableSize
protected SymbolHash.Entry[] fBuckets
protected int fNum
protected int[] fHashMultipliers
null
if the default String.hashCode() function should be used.public SymbolHash()
public SymbolHash(int size)
size
- the size of the key table.public void put(Object key, Object value)
key
- value
- public Object get(Object key)
key
- public int getLength()
public int getValues(Object[] elements, int from)
elements
- the array to store the elementsfrom
- where to start store element in the arraypublic Object[] getEntries()
public SymbolHash makeClone()
public void clear()
protected SymbolHash.Entry search(Object key, int bucket)
protected int hash(Object key)
key
- The key to hash.protected void rehash()
protected void rebalance()
Copyright © 2019 JBoss by Red Hat. All rights reserved.