Package org.jgroups.util
Class IntHashMap<T>
- java.lang.Object
-
- org.jgroups.util.IntHashMap<T>
-
public class IntHashMap<T> extends java.lang.Object
A hashmap where keys have to be ints. The size is fixed and keys/values are stored in a simple array, e.g. [K1,V1, K2,V2, ... Kn,Vn]. The keys are indices into the array.
Typically populated at startup and then used in read-only mode. This implementation is unsynchronized, and keys and values have to be non-null. Note that removals and changes (e.g. adding the same key twice) are unsupported.
Note that this class does not lend itself to be used as a sparse array, ie. adding keys [0 .. 100] and then 5000 would create an array of length 5001, and waste the space between index 100 and 5000. Ideally, keys start as 0, so adding keys [50..100] would also waste the space for 50 keys.- Since:
- 5.0.0
- Author:
- Bela Ban
-
-
Constructor Summary
Constructors Constructor Description IntHashMap(int highest_key)
Creates an instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IntHashMap<T>
checkCapacity(int key)
boolean
containsKey(int k)
T
get(int k)
int
getCapacity()
boolean
isEmpty()
IntHashMap<T>
put(int key, T value)
int
size()
java.lang.String
toString()
-
-
-
Field Detail
-
table
protected T[] table
-
size
protected int size
-
-
Method Detail
-
getCapacity
public int getCapacity()
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
containsKey
public boolean containsKey(int k)
-
get
public T get(int k)
-
put
public IntHashMap<T> put(int key, T value)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
checkCapacity
protected IntHashMap<T> checkCapacity(int key)
-
-