Subclasses of this class are of the following form:
class FooMap
extends sun.util.PreHashedMap<String>
{
private FooMap() {
super(ROWS, SIZE, SHIFT, MASK);
}
protected void init(Object[] ht) {
ht[0] = new Object[] { "key-1", value_1 };
ht[1] = new Object[] { "key-2", value_2,
new Object { "key-3", value_3 } };
...
}
}
The init method is invoked by the PreHashedMap
constructor with an object array long enough for the map's rows. The method
must construct the hash chain for each row and store it in the appropriate
element of the array.
Each entry in the map is represented by a unique hash-chain node. The final node of a hash chain is a two-element object array whose first element is the entry's key and whose second element is the entry's value. A non-final node of a hash chain is a three-element object array whose first two elements are the entry's key and value and whose third element is the next node in the chain.
Instances of this class are mutable and are not safe for concurrent
access. They may be made immutable and thread-safe via the appropriate
methods in the java. utility class.
In the JDK build, subclasses of this class are typically created via the
Hasher program in the make/tools/Hasher directory.
java.util.AbstractMap
| Modifier and Type | Field and Description |
|---|---|
| private final Object[] | |
| private final int | |
| private final int | |
| private final int | |
| private final int |
| Access | Constructor and Description |
|---|---|
| protected | PreHashedMap(int
The number of rows in the map rows, int The number of entries in the map size, int The value by which hash codes are right-shifted shift, int The value with which hash codes are masked after being shifted mask)Creates a new map. |
| Modifier and Type | Method and Description |
|---|---|
| public Set | entrySet()
Implements abstract java. Implements java. Returns a |
| public V | get(Object k)
Overrides java. Implements java. Returns the value to which the specified key is mapped,
or |
| protected abstract void | |
| public Set | keySet()
Overrides java. Implements java. Returns a |
| public V | put(String k, V v)
Overrides java. Implements java. Associates the specified value with the specified key in this map (optional operation). |
| private V |
| ht | back to summary |
|---|---|
| private final Object[] ht | |
| mask | back to summary |
|---|---|
| private final int mask | |
| rows | back to summary |
|---|---|
| private final int rows | |
| shift | back to summary |
|---|---|
| private final int shift | |
| size | back to summary |
|---|---|
| private final int size | |
| PreHashedMap | back to summary |
|---|---|
| protected PreHashedMap(int rows, int size, int shift, int mask) Creates a new map. This constructor invokes the
| |
| entrySet | back to summary |
|---|---|
| public Set Implements abstract java. Implements java. Doc from java. Returns a | |
| get | back to summary |
|---|---|
| public V get(Object k) Overrides java. Implements java. Doc from java. Returns the value to which the specified key is mapped,
or More formally, if this map contains a mapping from a key
If this map permits null values, then a return value of
| |
| init | back to summary |
|---|---|
| protected abstract void init(Object[] ht) Initializes this map. This method must construct the map's hash chains and store them into the appropriate elements of the given hash-table row array.
| |
| keySet | back to summary |
|---|---|
| public Set Overrides java. Implements java. Doc from java. Returns a | |
| put | back to summary |
|---|---|
| public V put(String k, V v) Overrides java. Implements java. Doc from java. Associates the specified value with the specified key in this map
(optional operation). If the map previously contained a mapping for
the key, the old value is replaced by the specified value. (A map
| |
| toV | back to summary |
|---|---|
private V toV(Object x)
| |