- java.lang.Object
-
- org.chocosolver.util.objects.IntMap
-
public class IntMap extends Object
A specific implementation for hash map of integers wherein all keys and values are greater or equal to 0.Created by cprudhom on 20/10/2015. Project: choco.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all of the mappings from this map.void
clear(int key)
Remove the value to which the specified key is mapped.boolean
containsKey(int key)
Returns true if this map contains a mapping for the specified key.int
get(int key)
Returns the value to which the specified key is mapped, or-1
if this map contains no mapping for the key.boolean
isEmpty()
Returns true if this map contains no elements.void
put(int key, int value)
Associates the specified value with the specified key in this map.void
putOrAdjust(int key, int value, int inc)
Adjusts the specified value associated with the specified key in this map.int
size()
Returns the number of elements in this map.
-
-
-
Method Detail
-
size
public int size()
Returns the number of elements in this map.- Returns:
- the number of elements in this map.
-
isEmpty
public boolean isEmpty()
Returns true if this map contains no elements.- Returns:
- true if this map contains no elements.
-
put
public void put(int key, int value)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.- Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key
-
putOrAdjust
public void putOrAdjust(int key, int value, int inc)
Adjusts the specified value associated with the specified key in this map. If the map previously contained a mapping for the key, the old value is adjusted, otherwise, the value is put.- Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyinc
- increment to add to the value associated with the key
-
get
public int get(int key)
Returns the value to which the specified key is mapped, or-1
if this map contains no mapping for the key.More formally, if this map contains a mapping from a key
k
to a valuev
such that(key==-1 ? k==-1 : key == k)
, then this method returnsv
; otherwise it returns-1
. (There can be at most one such mapping.)A return value of
#FREE
necessarily indicate that the map contains no mapping for the key.- See Also:
put(int, int)
-
containsKey
public boolean containsKey(int key)
Returns true if this map contains a mapping for the specified key.- Parameters:
key
- The key whose presence in this map is to be tested- Returns:
- true if this map contains a mapping for the specified key.
-
clear
public void clear(int key)
Remove the value to which the specified key is mapped.- Parameters:
key
- key with which the specified value is to be cleared
-
clear
public void clear()
Removes all of the mappings from this map. The map will be empty after this call returns.
-
-