Interface IntMap<V>
-
- All Known Implementing Classes:
IntHashMap,IntRWHashMap
public interface IntMap<V>The map for integer keys.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceIntMap.EntryConsumer<V,E extends Throwable>The bridge for consuming all entries of the map.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclear()Removes all of the mappings from this map.default VcomputeIfAbsent(int key, IntFunction<? extends V> mappingFunction)If the specified key is not already associated with a value (or is mapped tonull), attempts to compute its value using the given mapping function and enters it into this map unlessnull.booleancontainsKey(int key)Returns true if the map contains the key, otherwise false.booleancontainsValue(V val)Returns true if the map contains one or more values, otherwise false.<E extends Throwable>
voidforEach(IntMap.EntryConsumer<V,E> act)This method work under a read lock, be careful with long operations inside.Vget(int key)Returns value associated with the key. if the map doesn't contain the key, returns null.booleanisEmpty()Returns true if this map contains no key-value mappings.int[]keys()Returns array of keys.Vput(int key, V val)Save the pair into the map.VputIfAbsent(int key, V val)Does put into the map if a pair isn't present, otherwise returns stored value.Vremove(int key)intsize()Returns count of elements.Collection<V>values()Returns a collection of values.
-
-
-
Method Detail
-
containsKey
boolean containsKey(int key)
Returns true if the map contains the key, otherwise false.- Parameters:
key- tests key value.
-
containsValue
boolean containsValue(V val)
Returns true if the map contains one or more values, otherwise false.- Parameters:
val- value to be associated with the specified key.
-
get
V get(int key)
Returns value associated with the key. if the map doesn't contain the key, returns null.- Parameters:
key- key with which the specified value is to be associated.
-
put
V put(int key, V val)
Save the pair into the map. If a pair is present, returns old value and store new.- Parameters:
key- key with which the specified value is to be associated.val- value to be associated with the specified key.
-
remove
V remove(int key)
- Parameters:
key- key with which the specified value is to be associated.
-
putIfAbsent
V putIfAbsent(int key, V val)
Does put into the map if a pair isn't present, otherwise returns stored value.- Parameters:
key- key with which the specified value is to be associated..val- value to be associated with the specified key..
-
forEach
<E extends Throwable> void forEach(IntMap.EntryConsumer<V,E> act) throws E extends Throwable
This method work under a read lock, be careful with long operations inside.- Parameters:
act- Action.- Throws:
E extends Throwable
-
size
int size()
Returns count of elements.
-
isEmpty
boolean isEmpty()
Returns true if this map contains no key-value mappings.
-
keys
int[] keys()
Returns array of keys.
-
values
Collection<V> values()
Returns a collection of values.
-
clear
void clear()
Removes all of the mappings from this map.
-
computeIfAbsent
@Nullable default V computeIfAbsent(int key, IntFunction<? extends V> mappingFunction)
If the specified key is not already associated with a value (or is mapped tonull), attempts to compute its value using the given mapping function and enters it into this map unlessnull.- Parameters:
key- Key with which the specified value is to be associated.mappingFunction- Function to compute a value.- Returns:
- Current (existing or computed) value.
- Throws:
NullPointerException- If the mappingFunction is null.
-
-