|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.util.collections.AbstractHashMap prefuse.util.collections.IntObjectHashMap
public class IntObjectHashMap
Hash map holding (key,value) associations of type (int-->Object); Automatically grows and shrinks as needed; Implemented using open addressing with double hashing. First see the package summary and javadoc tree view to get the broad picture. This class has been adapted from the corresponding class in the COLT library for scientfic computing.
HashMap
Field Summary | |
---|---|
protected static int |
defaultCapacity
|
protected static double |
defaultMaxLoadFactor
|
protected static double |
defaultMinLoadFactor
|
protected static byte |
FREE
|
protected int |
freeEntries
The number of table entries in state==FREE. |
protected static byte |
FULL
|
protected static byte |
REMOVED
|
protected byte[] |
state
The state of each hash table entry (FREE, FULL, REMOVED). |
protected int[] |
table
The hash table keys. |
protected java.lang.Object[] |
values
The hash table values. |
Fields inherited from class prefuse.util.collections.AbstractHashMap |
---|
distinct, highWaterMark, lowWaterMark, maxLoadFactor, minLoadFactor |
Constructor Summary | |
---|---|
IntObjectHashMap()
Constructs an empty map with default capacity and default load factors. |
|
IntObjectHashMap(int initialCapacity)
Constructs an empty map with the specified initial capacity and default load factors. |
|
IntObjectHashMap(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Constructs an empty map with the specified initial capacity and the specified minimum and maximum load factor. |
Method Summary | |
---|---|
void |
clear()
Removes all (key,value) associations from the receiver. |
java.lang.Object |
clone()
Returns a deep copy of the receiver. |
boolean |
containsKey(int key)
Returns true if the receiver contains the specified key. |
boolean |
containsValue(java.lang.Object value)
Returns true if the receiver contains the specified value. |
void |
ensureCapacity(int minCapacity)
Ensures that the receiver can hold at least the specified number of associations without needing to allocate new internal memory. |
java.lang.Object |
get(int key)
Returns the value associated with the specified key. |
protected int |
indexOfInsertion(int key)
|
protected int |
indexOfKey(int key)
|
protected int |
indexOfValue(java.lang.Object value)
|
int |
keyOf(java.lang.Object value)
Returns the first key the given value is associated with. |
int |
keys(int[] list)
Fills all keys contained in the receiver into the specified list. |
boolean |
put(int key,
java.lang.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. |
boolean |
removeKey(int key)
Removes the given key with its associated element from the receiver, if present. |
protected void |
setUp(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Initializes the receiver. |
void |
trimToSize()
Trims the capacity of the receiver to be the receiver's current size. |
void |
values(java.util.ArrayList list)
Fills all values contained in the receiver into the specified list. |
Methods inherited from class prefuse.util.collections.AbstractHashMap |
---|
chooseGrowCapacity, chooseHighWaterMark, chooseLowWaterMark, chooseMeanCapacity, chooseShrinkCapacity, isEmpty, nextPrime, size |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int defaultCapacity
protected static final double defaultMinLoadFactor
protected static final double defaultMaxLoadFactor
protected static final byte FREE
protected static final byte FULL
protected static final byte REMOVED
protected int[] table
protected java.lang.Object[] values
protected byte[] state
protected int freeEntries
Constructor Detail |
---|
public IntObjectHashMap()
public IntObjectHashMap(int initialCapacity)
initialCapacity
- the initial capacity of the map.
java.lang.IllegalArgumentException
- if the initial capacity is less than zero.public IntObjectHashMap(int initialCapacity, double minLoadFactor, double maxLoadFactor)
initialCapacity
- the initial capacity.minLoadFactor
- the minimum load factor.maxLoadFactor
- the maximum load factor.
java.lang.IllegalArgumentException
- if
initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor).Method Detail |
---|
public void clear()
clear
in class AbstractHashMap
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean containsKey(int key)
public boolean containsValue(java.lang.Object value)
public void ensureCapacity(int minCapacity)
This method never need be called; it is for performance tuning only. Calling this method before put()ing a large number of associations boosts performance, because the receiver will grow only once instead of potentially many times and hash collisions get less probable.
ensureCapacity
in class AbstractHashMap
minCapacity
- the desired minimum capacity.public java.lang.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.
protected int indexOfValue(java.lang.Object value)
value
- the value to be searched in the receiver.
public int keyOf(java.lang.Object value)
containsValue(Object)
whether
there exists an association from a key to this value.
value
- the value to search for.
public int keys(int[] list)
This method can be used to iterate over the keys of the receiver.
list
- the list to be filledpublic boolean put(int key, java.lang.Object value)
key
- the key the value shall be associated with.value
- the value to be associated.
protected void rehash(int newCapacity)
public boolean removeKey(int key)
key
- the key to be removed from the receiver.
protected void setUp(int initialCapacity, double minLoadFactor, double maxLoadFactor)
setUp
in class AbstractHashMap
initialCapacity
- the initial capacity of the receiver.minLoadFactor
- the minLoadFactor of the receiver.maxLoadFactor
- the maxLoadFactor of the receiver.
java.lang.IllegalArgumentException
- if
initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor).public void trimToSize()
trimToSize
in class AbstractHashMap
public void values(java.util.ArrayList list)
This method can be used to iterate over the values of the receiver.
list
- the list to be filled, can have any size.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |