public class ObjectToIntMap<K> extends Object
Constructor and Description |
---|
ObjectToIntMap()
Constructs a map with default capacity.
|
ObjectToIntMap(int capacity)
Constructs a map with given capacity.
|
Modifier and Type | Method and Description |
---|---|
protected int |
calcBaseHashIndex(K key)
Calculating the baseHash index using the internal
hashFactor . |
void |
clear()
Empties the map.
|
boolean |
containsKey(K key)
Checks if a given key exists in the map.
|
boolean |
containsValue(int o)
Checks if the given object exists in the map.
|
boolean |
equals(Object o) |
protected int |
find(K key)
Find the actual index of a given key.
|
int |
get(K key)
Returns the int mapped with the given key.
|
protected void |
grow()
Grows the map.
|
int |
hashCode() |
boolean |
isEmpty() |
IntIterator |
iterator()
Returns a new iterator for the mapped objects.
|
Iterator<K> |
keyIterator() |
int |
put(K key,
int e)
Inserts the <key,value> pair into the map.
|
int |
remove(K key)
Removes a <key,value> pair from the map and returns the mapped value,
or 0 if the none existed.
|
int |
size() |
int[] |
toArray()
Translates the mapped pairs' values into an array of Objects
|
int[] |
toArray(int[] a)
Translates the mapped pairs' values into an array of T
|
String |
toString() |
public ObjectToIntMap()
public ObjectToIntMap(int capacity)
capacity
- minimum capacity for the map.protected int calcBaseHashIndex(K key)
hashFactor
.key
- public void clear()
public boolean containsKey(K key)
key
- that is checked against the map data.public boolean containsValue(int o)
o
- object that is checked against the map data.protected int find(K key)
key
- public int get(K key)
key
- int who's mapped object we're interested in.protected void grow()
public boolean isEmpty()
public IntIterator iterator()
public int put(K key, int e)
public int remove(K key)
key
- used to find the value to removepublic int size()
public int[] toArray()
public int[] toArray(int[] a)
a
- the array into which the elements of the list are to be
stored, if it is big enough; otherwise, use as much space as it can.