Class Int2HashMap<V>
java.lang.Object
de.tomatengames.util.map.Int2HashMap<V>
- Type Parameters:
V- The type of the values.
A
HashMap-like data structure that maps (int, int) keys to object values.
Equality of keys is checked by using the == operator
This map does not allow null values.
This implementation does not allow concurrent modifications.
- Since:
- 1.3
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new and emptyInt2HashMap.Int2HashMap(Int2HashMap<V> map) Creates a newInt2HashMapthat contains all the mappings of the specified map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all entries from this map.booleancontainsKey(int key1, int key2) Returns if the specified key is present in this map.booleanvoidget(int key1, int key2) Returns the value that is mapped to the specified key.inthashCode()booleanisEmpty()Returns if this map does not contain any entry.iterator()Associates the specified key with the specified value.voidputAll(Int2HashMap<V> otherMap) Puts all mappings of the specified map into this map.putIfAbsent(int key1, int key2, V value) Associates the specified key with the specified value.remove(int key1, int key2) Removes the entry with the specified key from this map.longsize()Returns the number of entries in this map.Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
spliterator
-
Constructor Details
-
Int2HashMap
public Int2HashMap()Creates a new and emptyInt2HashMap. -
Int2HashMap
Creates a newInt2HashMapthat contains all the mappings of the specified map.- Parameters:
map- The mappings that should be cloned.
-
-
Method Details
-
size
public long size()Returns the number of entries in this map.- Returns:
- The number of entries.
-
isEmpty
public boolean isEmpty()Returns if this map does not contain any entry.- Returns:
- If this map has no entries.
-
put
Associates the specified key with the specified value. If the key is already present in this map, the previous value is replaced.- Parameters:
key1- A component of the key of the new mapping.key2- A component of the key of the new mapping.value- The value of the new mapping. Must notnull.- Returns:
- The value that was previously mapped to the key.
If the key was not present in this map,
nullis returned. - Throws:
IllegalArgumentException- If the value isnull.
-
putIfAbsent
Associates the specified key with the specified value. If the key is already present in this map, nothing happens.- Parameters:
key1- A component of the key of the new mapping.key2- A component of the key of the new mapping.value- The value of the new mapping. Must notnull.- Returns:
- The value that was previously mapped to the key.
If
null, the new value has been put into the map. Otherwise, the previous value is still present. - Throws:
IllegalArgumentException- If the value isnull.
-
get
Returns the value that is mapped to the specified key.- Parameters:
key1- A component of the key whose value should be returned.key2- A component of the key whose value should be returned.- Returns:
- The value that the specified key is mapped to.
If this map does not contain the key,
nullis returned.
-
containsKey
public boolean containsKey(int key1, int key2) Returns if the specified key is present in this map. This method is semantically equivalent toget(key) != null
- Parameters:
key1- A component of the key that should be checked.key2- A component of the key that should be checked.- Returns:
- If the specified key is present in this map.
-
remove
Removes the entry with the specified key from this map. If the map does not contain the key, nothing happens.- Parameters:
key1- A component of the key of the entry that should be removed.key2- A component of the key of the entry that should be removed.- Returns:
- The value of the entry that was removed.
If no entry was removed,
nullis returned.
-
clear
public void clear()Removes all entries from this map. -
forEach
-
putAll
Puts all mappings of the specified map into this map. Keys that are present in both maps are replaced in this map. If the specified map isnullor this map, nothing happens.- Parameters:
otherMap- The map whose mappings should be put into this map. May benull.
-
equals
-
hashCode
-
iterator
-