public interface IntObjMap<V> extends Map<Integer,V>, Container
IntObjMapFactory
,
@KolobokeMap
Modifier and Type | Method and Description |
---|---|
V |
compute(Integer key,
BiFunction<? super Integer,? super V,? extends V> remappingFunction)
Deprecated.
Use specialization
compute(int, IntObjFunction) instead |
V |
compute(int key,
IntObjFunction<? super V,? extends V> remappingFunction)
Attempts to compute a mapping for the specified key and its current mapped value
(or
null if there is no current mapping). |
V |
computeIfAbsent(Integer key,
Function<? super Integer,? extends V> mappingFunction)
Deprecated.
Use specialization
computeIfAbsent(int, IntFunction) instead |
V |
computeIfAbsent(int key,
IntFunction<? extends V> mappingFunction)
If the specified key is not already associated with a value (or is mapped to
null ), attempts
to compute its value using the given mapping function and enters it into this map
unless null . |
V |
computeIfPresent(Integer key,
BiFunction<? super Integer,? super V,? extends V> remappingFunction)
Deprecated.
Use specialization
computeIfPresent(int, IntObjFunction) instead |
V |
computeIfPresent(int key,
IntObjFunction<? super V,? extends V> remappingFunction)
If the value for the specified key is present and non-null,
attempts to compute a new mapping given the key and its current mapped value.
|
boolean |
containsKey(int key)
Returns
true if this map contains a mapping for the specified key. |
boolean |
containsKey(Object key)
Deprecated.
Use specialization
containsKey(int) instead |
IntObjCursor<V> |
cursor()
Returns a new cursor over the entries of this map.
|
ObjSet<Map.Entry<Integer,V>> |
entrySet() |
void |
forEach(BiConsumer<? super Integer,? super V> action)
Deprecated.
Use specialization
forEach(IntObjConsumer) instead |
void |
forEach(IntObjConsumer<? super V> action)
Performs the given
action on each entry in this map until all entries
have been processed or the action throws an Exception . |
boolean |
forEachWhile(IntObjPredicate<? super V> predicate)
Checks the given
predicate on each entry in this map until all entries
have been processed or the predicate returns false for some entry,
or throws an Exception . |
V |
get(int key)
Returns the value to which the specified key is mapped, or
null if this map
contains no mapping for the key. |
V |
get(Object key)
Deprecated.
Use specialization
get(int) instead |
V |
getOrDefault(int key,
V defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map
contains no mapping for the key. |
V |
getOrDefault(Object key,
V defaultValue)
Deprecated.
Use specialization
getOrDefault(int, Object) instead |
IntSet |
keySet() |
V |
merge(Integer key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction)
Deprecated.
Use specialization
merge(int, Object, BiFunction) instead |
V |
merge(int key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction)
If the specified key is not already associated with a value (or is mapped to
null ), associates
it with the given value, otherwise, replaces the value with the results of the given
remapping function. |
V |
put(Integer key,
V value)
Deprecated.
Use specialization
put(int, Object) instead |
V |
put(int key,
V value)
Associates the specified value with the specified key in this map (optional operation).
|
V |
putIfAbsent(Integer key,
V value)
Deprecated.
Use specialization
putIfAbsent(int, Object) instead |
V |
putIfAbsent(int key,
V value)
If the specified key is not already associated with a value (or is mapped to
null ), associates
it with the given value and returns null , else returns the current value. |
V |
remove(int key)
Removes the mapping for a key from this map if it is present (optional operation).
|
boolean |
remove(int key,
Object value)
Removes the entry for the specified key only if it is currently mapped to the specified
value.
|
V |
remove(Object key)
Deprecated.
Use specialization
remove(int) instead |
boolean |
remove(Object key,
Object value)
Deprecated.
Use specialization
remove(int, Object) instead |
boolean |
removeIf(IntObjPredicate<? super V> filter)
Removes all of the entries of this collection that satisfy the given predicate.
|
V |
replace(Integer key,
V value)
Deprecated.
Use specialization
replace(int, Object) instead |
boolean |
replace(Integer key,
V oldValue,
V newValue)
Deprecated.
Use specialization
replace(int, Object, Object) instead |
V |
replace(int key,
V value)
Replaces the entry for the specified key only if it is currently mapped to some value.
|
boolean |
replace(int key,
V oldValue,
V newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.
|
void |
replaceAll(BiFunction<? super Integer,? super V,? extends V> function)
Deprecated.
Use specialization
replaceAll(IntObjFunction) instead |
void |
replaceAll(IntObjFunction<? super V,? extends V> function)
Replaces each entry's value with the result of invoking the given function on that entry,
in the order entries are returned by an entry set iterator, until all entries have been
processed or the function throws an exception.
|
Equivalence<V> |
valueEquivalence()
Returns the equivalence strategy for values in this map.
|
ObjCollection<V> |
values() |
clear, ensureCapacity, isEmpty, shrink, size, sizeAsLong
@Nonnull Equivalence<V> valueEquivalence()
Map
interface which defined in terms of Object.equals(Object)
equality of value objects,
for example, Map.containsValue(Object)
and remove(int, Object)
,
are supposed to use this equivalence instead.IntObjMapFactory.withValueEquivalence(com.koloboke.collect.Equivalence<? super V>)
@Deprecated boolean containsKey(Object key)
containsKey(int)
insteadcontainsKey
in interface Map<Integer,V>
boolean containsKey(int key)
true
if this map contains a mapping for the specified key.key
- the int
key whose presence in this map is to be testedtrue
if this map contains a mapping for the specified key@Nullable @Deprecated V get(Object key)
get(int)
instead@Nullable V get(int key)
null
if this map
contains no mapping for the key.
If this map permits null values, then a return value of null
does not
necessarily indicate that the map contains no mapping for the key; it's also possible
that the map explicitly maps the key to null
. The containsKey(java.lang.Object)
operation may be used to distinguish these two cases.
key
- the key whose associated value is to be returnednull
if this map
contains no mapping for the key@Deprecated V getOrDefault(Object key, V defaultValue)
getOrDefault(int, Object)
insteadgetOrDefault
in interface Map<Integer,V>
V getOrDefault(int key, V defaultValue)
defaultValue
if this map
contains no mapping for the key.key
- the key whose associated value is to be returneddefaultValue
- the value to return if the specified key
is absent in the mapdefaultValue
if this map contains no mapping for the key@Deprecated void forEach(@Nonnull BiConsumer<? super Integer,? super V> action)
forEach(IntObjConsumer)
insteadvoid forEach(@Nonnull IntObjConsumer<? super V> action)
action
on each entry in this map until all entries
have been processed or the action throws an Exception
.
Exceptions thrown by the action are relayed to the caller. The entries
will be processed in the same order as the entry set iterator unless that
order is unspecified in which case implementations may use an order which
differs from the entry set iterator.action
- The action to be performed for each entryboolean forEachWhile(@Nonnull IntObjPredicate<? super V> predicate)
predicate
on each entry in this map until all entries
have been processed or the predicate returns false
for some entry,
or throws an Exception
. Exceptions thrown by the predicate are relayed to the caller.
The entries will be processed in the same order as the entry set iterator unless that order is unspecified in which case implementations may use an order which differs from the entry set iterator.
If the map is empty, this method returns true
immediately.
predicate
- the predicate to be checked for each entrytrue
if the predicate returned true
for all entries of the map,
false
if it returned false
for the entry@Nonnull IntObjCursor<V> cursor()
Basic cursor usage idiom is:
for (IntObjCursor<V> cur = map.cursor(); cur.moveNext();) {
// Work with cur.key() and cur.value()
// Call cur.remove() to remove the current entry
}
@Deprecated V put(Integer key, V value)
put(int, Object)
insteadV put(int key, V value)
m
is said to contain a mapping for a key k
if and only if m.containsKey(k)
would return true
.)key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keykey
, or null
if there was
no mapping for key
. (A null
return can also indicate that the map
previously associated null
with key
.)UnsupportedOperationException
- if the put
operation
is not supported by this mapClassCastException
- if the class of the specified value
prevents it from being stored in this mapNullPointerException
- if the specified value is null,
and this map does not permit null values * @throws IllegalArgumentException if some property of a specified key
or value prevents it from being stored in this map@Nullable @Deprecated V putIfAbsent(Integer key, V value)
putIfAbsent(int, Object)
insteadnull
), associates
it with the given value and returns null
, else returns the current value.putIfAbsent
in interface Map<Integer,V>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keynull
if there was no mapping for the key.
(A null
return can also indicate that the map
previously associated null
with the key,
if the implementation supports null values.)UnsupportedOperationException
- if the put
operation
is not supported by this mapClassCastException
- if the key or value is of an inappropriate type for this mapNullPointerException
- if the specified key is nullIllegalArgumentException
- if some property of the specified key
or value prevents it from being stored in this map@Nullable V putIfAbsent(int key, V value)
null
), associates
it with the given value and returns null
, else returns the current value.key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keynull
if there was no mapping for the key. (A null
return
can also indicate that the map previously associated null
with the key, if the implementation supports such values.)UnsupportedOperationException
- if the put
operation
is not supported by this mapClassCastException
- if the class of the specified value
prevents it from being stored in this mapNullPointerException
- if the specified value is null,
and this map does not permit null values * @throws IllegalArgumentException if some property of a specified key
or value prevents it from being stored in this map@Deprecated V compute(Integer key, @Nonnull BiFunction<? super Integer,? super V,? extends V> remappingFunction)
compute(int, IntObjFunction)
insteadV compute(int key, @Nonnull IntObjFunction<? super V,? extends V> remappingFunction)
null
if there is no current mapping).
If the function returns null
, the mapping is removed (or
remains absent if initially absent).
If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.
key
- key with which the specified value is to be associatedremappingFunction
- the function to compute a valueClassCastException
- if the class of the
computed value
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this map@Deprecated V computeIfAbsent(Integer key, @Nonnull Function<? super Integer,? extends V> mappingFunction)
computeIfAbsent(int, IntFunction)
insteadcomputeIfAbsent
in interface Map<Integer,V>
V computeIfAbsent(int key, @Nonnull IntFunction<? extends V> mappingFunction)
null
), attempts
to compute its value using the given mapping function and enters it into this map
unless null
. The most common usage is to construct
a new object serving as an initial mapped value or memoized result.
If the function returns null
no mapping is recorded.
If the function itself throws an (unchecked) exception, the exception is rethrown, and no mapping is recorded.
key
- key with which the specified value is to be associatedmappingFunction
- the function to compute a valueClassCastException
- if the class of the
computed value
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this map@Deprecated V computeIfPresent(Integer key, @Nonnull BiFunction<? super Integer,? super V,? extends V> remappingFunction)
computeIfPresent(int, IntObjFunction)
insteadcomputeIfPresent
in interface Map<Integer,V>
V computeIfPresent(int key, @Nonnull IntObjFunction<? super V,? extends V> remappingFunction)
If the function returns null
, the mapping is removed.
If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.
key
- key with which the specified value is to be associatedremappingFunction
- the function to compute a valueClassCastException
- if the class of the
computed value
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this map@Deprecated V merge(Integer key, V value, @Nonnull BiFunction<? super V,? super V,? extends V> remappingFunction)
merge(int, Object, BiFunction)
insteadV merge(int key, V value, @Nonnull BiFunction<? super V,? super V,? extends V> remappingFunction)
null
), associates
it with the given value, otherwise, replaces the value with the results of the given
remapping function.
This method may be of use when combining multiple mapped values for a key.
If the function returns null
, the mapping is removed.
If the remappingFunction itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.
key
- key with which the specified value is to be associatedvalue
- the value to use if absentremappingFunction
- the function to recompute a value if presentNullPointerException
- if the remappingFunction
is nullClassCastException
- if the class of the
computed value
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this map@Nullable @Deprecated V replace(Integer key, V value)
replace(int, Object)
insteadreplace
in interface Map<Integer,V>
key
- key with which the specified value is associatedvalue
- value to be associated with the specified keynull
if there was
no mapping for the key. (A null
return can also indicate
that the map previously associated null
with the key,
if the implementation supports null values.)UnsupportedOperationException
- if the put
operation
is not supported by this mapNullPointerException
- if the specified key is nullIllegalArgumentException
- if some property of the specified value
prevents it from being stored in this map@Nullable V replace(int key, V value)
key
- key with which the specified value is associatedvalue
- value to be associated with the specified keynull
if there was no mapping for the key.
(A null
return can also indicate that the map
previously associated null
with the key,
if the implementation supports such values.)ClassCastException
- if the class of the specified value
prevents it from being stored in this mapNullPointerException
- if the specified value is null,
and this map does not permit null values * @throws IllegalArgumentException if some property of a specified key
or value prevents it from being stored in this mapUnsupportedOperationException
- if the put
operation
is not supported by this map@Deprecated boolean replace(Integer key, V oldValue, V newValue)
replace(int, Object, Object)
insteadreplace
in interface Map<Integer,V>
key
- key with which the specified value is associatedoldValue
- value expected to be associated with the specified keynewValue
- value to be associated with the specified keytrue
if the value was replacedUnsupportedOperationException
- if the put
operation
is not supported by this mapNullPointerException
- if the specified key is nullIllegalArgumentException
- if some property of the specified value
prevents it from being stored in this mapboolean replace(int key, V oldValue, V newValue)
key
- key with which the specified value is associatedoldValue
- value expected to be associated with the specified keynewValue
- value to be associated with the specified keytrue
if the value was replacedClassCastException
- if the class of the specified value
prevents it from being stored in this mapNullPointerException
- if the specified value is null,
and this map does not permit null values * @throws IllegalArgumentException if some property of a specified key
or value prevents it from being stored in this mapUnsupportedOperationException
- if the put
operation
is not supported by this map@Deprecated void replaceAll(@Nonnull BiFunction<? super Integer,? super V,? extends V> function)
replaceAll(IntObjFunction)
insteadreplaceAll
in interface Map<Integer,V>
void replaceAll(@Nonnull IntObjFunction<? super V,? extends V> function)
function
- the function to apply to each entryUnsupportedOperationException
- if the set
operation
is not supported by this map's entry set iterator
or the specified replacement value is null, and this map does not permit
null values (optional restriction)ClassCastException
- if the class of a replacement value
prevents it from being stored in this mapIllegalArgumentException
- if some property of a replacement value
prevents it from being stored in this map (optional restriction)@Nullable @Deprecated V remove(Object key)
remove(int)
instead@Nullable V remove(int key)
Returns the value to which this map previously associated the key, or null
if the map contained no mapping for the key.
A return value of null
does not necessarily indicate that the map
contained no mapping for the key; it's also possible that the map
explicitly mapped the key to null
.
The map will not contain a mapping for the specified key once the call returns.
key
- key whose mapping is to be removed from the mapkey
, or null
if there was
no mapping for key
ClassCastException
- if the class of the specified value
prevents it from being stored in this map (optional restriction)NullPointerException
- if the specified value is null,
and this map does not permit null values (optional restriction)UnsupportedOperationException
- if the remove
operation
is not supported by this map@Deprecated boolean remove(Object key, Object value)
remove(int, Object)
insteadremove
in interface Map<Integer,V>
key
- key with which the specified value is associatedvalue
- value expected to be associated with the specified keytrue
if the value was removedNullPointerException
- if the specified key is null
, or if the specified value is null,
and this map does not permit null values (optional restriction)ClassCastException
- if the class of the specified value
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the remove
operation
is not supported by this mapboolean remove(int key, Object value)
key
- key with which the specified value is associatedvalue
- value expected to be associated with the specified keytrue
if the value was removedClassCastException
- if the class of the specified value
prevents it from being stored in this map (optional restriction)NullPointerException
- if the specified value is null,
and this map does not permit null values (optional restriction)UnsupportedOperationException
- if the remove
operation
is not supported by this mapboolean removeIf(@Nonnull IntObjPredicate<? super V> filter)
filter
- a predicate which returns true
for elements to be removedtrue
if any elements were removedNullPointerException
- if the specified filter is nullUnsupportedOperationException
- if elements cannot be removed from this collection.
Implementations may throw this exception if a matching element cannot be removed
or if, in general, removal is not supported.