public class IntToIntHashMap extends java.lang.Object implements IntToIntMap
| Constructor and Description |
|---|
IntToIntHashMap()
Initializes a map with a capacity of 8 and a load factor of 0,25.
|
IntToIntHashMap(int capacity)
Initializes a map with the given capacity and a load factor of 0,25.
|
IntToIntHashMap(int capacity,
double factor)
Constructs a new map with initial capacity, and load factor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the map.
|
boolean |
find(int key)
Finds a key in the map.
|
int |
get(int key)
Gets the value for this key.
|
int |
getDefaultValue()
Get the default value used to indicate an unused entry
|
IntIterator |
keyIterator()
Get an iterator over the integer key values held in the hash map
|
void |
put(int key,
int value)
Adds a key-value pair to the map.
|
boolean |
remove(int key)
Removes a key from the map.
|
void |
setDefaultValue(int defaultValue)
Set the value to be returned to indicate an unused entry
|
int |
size()
Gets the size of the map.
|
java.lang.String |
toString()
The toString() method on this class is designed for diagnostics only, and the output
should not be regarded as stable between releases.
|
public IntToIntHashMap()
public IntToIntHashMap(int capacity)
capacity - the initial capacity.public IntToIntHashMap(int capacity,
double factor)
The capacity is the number of keys that can be mapped without resizing the arrays in which keys and values are stored. For efficiency, only a fraction of the elements in those arrays are used. That fraction is the specified load factor. The initial length of the arrays equals the smallest power of two not less than the ratio capacity/factor. The capacity of the map is increased, as necessary. The maximum number of keys that can be mapped is 2^30.
capacity - the initial capacity.factor - the load factor.public void setDefaultValue(int defaultValue)
setDefaultValue in interface IntToIntMapdefaultValue - the value to be returned by get(int) if no entry
exists for the supplied keypublic int getDefaultValue()
getDefaultValue in interface IntToIntMapget(int) if no entry
exists for the supplied keypublic void clear()
clear in interface IntToIntMappublic boolean find(int key)
find in interface IntToIntMapkey - Keypublic int get(int key)
get in interface IntToIntMapkey - Keypublic int size()
size in interface IntToIntMappublic boolean remove(int key)
remove in interface IntToIntMapkey - Key to removepublic void put(int key,
int value)
put in interface IntToIntMapkey - Keyvalue - Valuepublic IntIterator keyIterator()
keyIterator in interface IntToIntMappublic java.lang.String toString()
toString in class java.lang.ObjectCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.