public class OpenIntObjectHashMap extends Object
HashMap| Modifier and Type | Field and Description |
|---|---|
protected int |
distinct
The number of distinct associations in the map; its "size()".
|
protected int |
freeEntries
The number of table entries in state==FREE.
|
protected double |
maxLoadFactor
The maximum load factor for the hashtable.
|
protected double |
minLoadFactor
The minimum load factor for the hashtable.
|
protected byte[] |
state
The state of each hash table entry (FREE, FULL, REMOVED).
|
protected int[] |
table
The hash table keys.
|
protected Object[] |
values
The hash table values.
|
| Constructor and Description |
|---|
OpenIntObjectHashMap()
Constructs an empty map with default capacity and default load factors.
|
OpenIntObjectHashMap(int initialCapacity)
Constructs an empty map with the specified initial capacity and default
load factors.
|
OpenIntObjectHashMap(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Constructs an empty map with the specified initial capacity and the
specified minimum and maximum load factor.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
chooseGrowCapacity(int size,
double minLoad,
double maxLoad)
Chooses a new prime table capacity optimized for growing that
(approximately) satisfies the invariant
c * minLoadFactor <= size <= c * maxLoadFactor and has at least
one FREE slot for the given size.
|
protected int |
chooseHighWaterMark(int capacity,
double maxLoad)
Returns new high water mark threshold based on current capacity and
maxLoadFactor.
|
protected int |
chooseShrinkCapacity(int size,
double minLoad,
double maxLoad)
Chooses a new prime table capacity optimized for shrinking that
(approximately) satisfies the invariant
c * minLoadFactor <= size <= c * maxLoadFactor and has at least
one FREE slot for the given size.
|
void |
clear()
Removes all entries from this map
|
boolean |
containsKey(int key)
Returns true if the receiver contains the specified key.
|
Object |
get(int key)
Returns the value associated with the specified key.
|
protected int |
indexOfInsertion(int key) |
protected int |
indexOfKey(int key) |
protected int |
nextPrime(int desiredCapacity)
Returns a prime number which is
>= desiredCapacity and
very close to desiredCapacity (within 11% if
desiredCapacity >= 1000). |
boolean |
put(int key,
Object value)
Associates the given key with the given value.
|
protected void |
rehash(int newCapacity)
Rehashes the contents of the receiver into a new table with a smaller or
larger capacity.
|
protected void |
setUp(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Initializes the receiver.
|
protected int[] table
protected Object[] values
protected byte[] state
protected int freeEntries
protected int distinct
protected double minLoadFactor
protected double maxLoadFactor
public OpenIntObjectHashMap()
public OpenIntObjectHashMap(int initialCapacity)
initialCapacity - the initial capacity of the map.IllegalArgumentException - if the initial capacity is less than zero.public OpenIntObjectHashMap(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
initialCapacity - the initial capacity.minLoadFactor - the minimum load factor.maxLoadFactor - the maximum load factor.IllegalArgumentException - if
initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor)
.public boolean containsKey(int key)
key - the key to test forpublic Object get(int key)
containsKey(int) whether the given key
has a value associated or not, i.e. whether there exists an association
for the given key or not.key - the key to be searched for.protected int indexOfInsertion(int key)
key - the key to be added to the receiver.protected int indexOfKey(int key)
key - the key to be searched in the receiver.public void clear()
protected int chooseGrowCapacity(int size,
double minLoad,
double maxLoad)
protected int nextPrime(int desiredCapacity)
>= desiredCapacity and
very close to desiredCapacity (within 11% if
desiredCapacity >= 1000).desiredCapacity - the capacity desired by the user.protected int chooseHighWaterMark(int capacity,
double maxLoad)
public boolean put(int key,
Object value)
key - the key the value shall be associated with.value - the value to be associated.protected void rehash(int newCapacity)
protected int chooseShrinkCapacity(int size,
double minLoad,
double maxLoad)
protected void setUp(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
initialCapacity - the initial capacity of the receiver.minLoadFactor - the minLoadFactor of the receiver.maxLoadFactor - the maxLoadFactor of the receiver.IllegalArgumentException - if
initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor)
.Copyright © 2016 Glasnost. All rights reserved.