public interface ObjLongMap<K> extends Map<K,Long>, Container
ObjLongMapFactory
,
@KolobokeMap
Modifier and Type | Method and Description |
---|---|
long |
addValue(K key,
long addition)
Adds the given value
addition to the value associated with the specified key,
or to the default value if this map contains no mapping for
the key, and associates the resulting value with the key. |
long |
addValue(K key,
long addition,
long initialValue)
Adds the given value
addition to the value associated with the specified key,
or the given initialValue if this map contains no mapping for the key, and associates
the resulting value with the key. |
Long |
compute(K key,
BiFunction<? super K,? super Long,? extends Long> remappingFunction)
Deprecated.
Use specialization
compute(Object, ObjLongToLongFunction) instead |
long |
compute(K key,
ObjLongToLongFunction<? super K> remappingFunction)
Attempts to compute a mapping for the specified key and its current mapped value
(or default
value if there is no current mapping).
|
Long |
computeIfAbsent(K key,
Function<? super K,? extends Long> mappingFunction)
Deprecated.
Use specialization
computeIfAbsent(Object, ToLongFunction) instead |
long |
computeIfAbsent(K key,
ToLongFunction<? super K> mappingFunction)
If the specified key is not already associated with a value, attempts
to compute its value using the given mapping function and enters it into this map
.
|
Long |
computeIfPresent(K key,
BiFunction<? super K,? super Long,? extends Long> remappingFunction)
Deprecated.
Use specialization
computeIfPresent(Object, ObjLongToLongFunction) instead |
long |
computeIfPresent(K key,
ObjLongToLongFunction<? super K> remappingFunction)
If the value for the specified key is present,
attempts to compute a new mapping given the key and its current mapped value.
|
boolean |
containsValue(long value)
Returns
true if this map maps one or more keys to the specified value. |
boolean |
containsValue(Object value)
Deprecated.
Use specialization
containsValue(long) instead |
ObjLongCursor<K> |
cursor()
Returns a new cursor over the entries of this map.
|
long |
defaultValue()
Returns the default value of this map, which is used instead of
null
in primitive specialization methods, when the key is absent in the map. |
ObjSet<Map.Entry<K,Long>> |
entrySet() |
void |
forEach(BiConsumer<? super K,? super Long> action)
Deprecated.
Use specialization
forEach(ObjLongConsumer) instead |
void |
forEach(ObjLongConsumer<? super K> 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(ObjLongPredicate<? super K> 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 . |
Long |
get(Object key)
Deprecated.
Use specialization
getLong(Object) instead |
long |
getLong(Object key)
Returns the value to which the specified key is mapped, or default
value if this map
contains no mapping for the key.
|
long |
getOrDefault(Object key,
long defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map
contains no mapping for the key. |
Long |
getOrDefault(Object key,
Long defaultValue)
Deprecated.
Use specialization
getOrDefault(Object, long) instead |
Equivalence<K> |
keyEquivalence()
Returns the equivalence strategy for keys in this map.
|
ObjSet<K> |
keySet() |
Long |
merge(K key,
Long value,
BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
Deprecated.
Use specialization
merge(Object, long, LongBinaryOperator) instead |
long |
merge(K key,
long value,
LongBinaryOperator remappingFunction)
If the specified key is not already associated with a value, associates
it with the given value, otherwise, replaces the value with the results of the given
remapping function.
|
long |
put(K key,
long value)
Associates the specified value with the specified key in this map (optional operation).
|
Long |
put(K key,
Long value)
Deprecated.
Use specialization
put(Object, long) instead |
long |
putIfAbsent(K key,
long value)
If the specified key is not already associated with a value, associates
it with the given value and returns default
value, else returns the current value.
|
Long |
putIfAbsent(K key,
Long value)
Deprecated.
Use specialization
putIfAbsent(Object, long) instead |
Long |
remove(Object key)
Deprecated.
Use specialization
removeAsLong(Object) instead |
boolean |
remove(Object key,
long value)
Removes the entry for the specified key only if it is currently mapped to the specified
value.
|
boolean |
remove(Object key,
Object value)
Deprecated.
Use specialization
remove(Object, long) instead |
long |
removeAsLong(Object key)
Removes the mapping for a key from this map if it is present (optional operation).
|
boolean |
removeIf(ObjLongPredicate<? super K> filter)
Removes all of the entries of this collection that satisfy the given predicate.
|
long |
replace(K key,
long value)
Replaces the entry for the specified key only if it is currently mapped to some value.
|
Long |
replace(K key,
Long value)
Deprecated.
Use specialization
replace(Object, long) instead |
boolean |
replace(K key,
long oldValue,
long newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.
|
boolean |
replace(K key,
Long oldValue,
Long newValue)
Deprecated.
Use specialization
replace(Object, long, long) instead |
void |
replaceAll(BiFunction<? super K,? super Long,? extends Long> function)
Deprecated.
Use specialization
replaceAll(ObjLongToLongFunction) instead |
void |
replaceAll(ObjLongToLongFunction<? super K> 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.
|
LongCollection |
values() |
clear, ensureCapacity, isEmpty, shrink, size, sizeAsLong
@Nonnull Equivalence<K> keyEquivalence()
Map
interface which defined in terms of Object.equals(Object)
equality of key objects
(almost all methods, actually), are supposed to use this equivalence instead.HashObjLongMapFactory.withKeyEquivalence(com.koloboke.collect.Equivalence<? super K>)
long defaultValue()
null
in primitive specialization methods, when the key is absent in the map.ObjLongMapFactory.withDefaultValue(long)
@Deprecated boolean containsValue(Object value)
containsValue(long)
insteadcontainsValue
in interface Map<K,Long>
boolean containsValue(long value)
true
if this map maps one or more keys to the specified value. This operation
will probably require time linear in the map size for most implementations
of the ObjLongMap
interface.value
- the long
value whose presence in this map is to be testedtrue
if this map maps one or more keys to the specified value@Nullable @Deprecated Long get(Object key)
getLong(Object)
insteadlong getLong(Object key)
More formally, if this map contains a mapping from a key k
to a value v
such that keyEquivalence() == null ? (key==null ? k==null : key.equals(k)) :
keyEquivalence().nullableEquivalent(k, key)
, then this method returns v
; otherwise
it returns default
value. (There can be at most one such mapping.)
key
- the key whose associated value is to be returnedClassCastException
- if the key is of an inappropriate type for
this map (optional restriction)NullPointerException
- if the specified key is null and this map does not permit
null keys (optional restriction)@Deprecated Long getOrDefault(Object key, Long defaultValue)
getOrDefault(Object, long)
insteadgetOrDefault
in interface Map<K,Long>
long getOrDefault(Object key, long 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 keyClassCastException
- if the key is of an inappropriate type for
this map (optional restriction)NullPointerException
- if the specified key is null and this map
does not permit null keys (optional restriction)@Deprecated void forEach(@Nonnull BiConsumer<? super K,? super Long> action)
forEach(ObjLongConsumer)
insteadvoid forEach(@Nonnull ObjLongConsumer<? super K> 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 ObjLongPredicate<? super K> 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 ObjLongCursor<K> cursor()
Basic cursor usage idiom is:
for (ObjLongCursor<K> cur = map.cursor(); cur.moveNext();) {
// Work with cur.key() and cur.value()
// Call cur.remove() to remove the current entry
}
@Deprecated Long put(K key, Long value)
put(Object, long)
insteadlong put(K key, long 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 default
value if there was
no mapping for key
. (A default
value return can also indicate that the map
previously associated default
value with key
.)UnsupportedOperationException
- if the put
operation
is not supported by this mapClassCastException
- if the class of the specified key
prevents it from being stored in this mapNullPointerException
- if the specified key is null,
and this map does not permit null keysIllegalArgumentException
- if some property of a specified key
or value prevents it from being stored in this map@Nullable @Deprecated Long putIfAbsent(K key, Long value)
putIfAbsent(Object, long)
insteadnull
, else returns the current value.putIfAbsent
in interface Map<K,Long>
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 value is nullIllegalArgumentException
- if some property of the specified key
or value prevents it from being stored in this maplong putIfAbsent(K key, long value)
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyUnsupportedOperationException
- if the put
operation
is not supported by this mapClassCastException
- if the class of the specified key
prevents it from being stored in this mapNullPointerException
- if the specified key is null,
and this map does not permit null keysIllegalArgumentException
- if some property of a specified key
or value prevents it from being stored in this map@Deprecated Long compute(K key, @Nonnull BiFunction<? super K,? super Long,? extends Long> remappingFunction)
compute(Object, ObjLongToLongFunction)
insteadlong compute(K key, @Nonnull ObjLongToLongFunction<? super K> remappingFunction)
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
specified key
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this map@Deprecated Long computeIfAbsent(K key, @Nonnull Function<? super K,? extends Long> mappingFunction)
computeIfAbsent(Object, ToLongFunction)
insteadcomputeIfAbsent
in interface Map<K,Long>
long computeIfAbsent(K key, @Nonnull ToLongFunction<? super K> mappingFunction)
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
specified key
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this map@Deprecated Long computeIfPresent(K key, @Nonnull BiFunction<? super K,? super Long,? extends Long> remappingFunction)
computeIfPresent(Object, ObjLongToLongFunction)
insteadcomputeIfPresent
in interface Map<K,Long>
long computeIfPresent(K key, @Nonnull ObjLongToLongFunction<? super K> remappingFunction)
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
specified key
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this map@Deprecated Long merge(K key, Long value, @Nonnull BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
merge(Object, long, LongBinaryOperator)
insteadlong merge(K key, long value, @Nonnull LongBinaryOperator remappingFunction)
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 null
or if the specified key is null and this map does not support null keys
or if the specified value is null and this map does not support null valuesClassCastException
- if the class of the
specified key
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this maplong addValue(K key, long addition)
addition
to the value associated with the specified key,
or to the default value if this map contains no mapping for
the key, and associates the resulting value with the key.key
- the key to which value add the given valueaddition
- the value additionClassCastException
- if the class of the
specified key
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this maplong addValue(K key, long addition, long initialValue)
addition
to the value associated with the specified key,
or the given initialValue
if this map contains no mapping for the key, and associates
the resulting value with the key.
This version of addValue(Object, long)
method is useful if you want
to accumulate values from the different initial value, than the default value of this map.
key
- the key to which value add the given valueaddition
- the value additioninitialValue
- the value to add the given value addition
to, if the map contains
no mapping for the given keyClassCastException
- if the class of the
specified key
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the put
operation
is not supported by this map@Nullable @Deprecated Long replace(K key, Long value)
replace(Object, long)
insteadreplace
in interface Map<K,Long>
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.UnsupportedOperationException
- if the put
operation
is not supported by this mapNullPointerException
- if the specified value is nullIllegalArgumentException
- if some property of the specified value
prevents it from being stored in this maplong replace(K key, long value)
key
- key with which the specified value is associatedvalue
- value to be associated with the specified keyClassCastException
- if the class of the specified key
prevents it from being stored in this mapNullPointerException
- if the specified key is null,
and this map does not permit null keysIllegalArgumentException
- 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(K key, Long oldValue, Long newValue)
replace(Object, long, long)
insteadreplace
in interface Map<K,Long>
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 value is nullIllegalArgumentException
- if some property of the specified value
prevents it from being stored in this mapboolean replace(K key, long oldValue, long 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 key
prevents it from being stored in this mapNullPointerException
- if the specified key is null,
and this map does not permit null keysIllegalArgumentException
- 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 K,? super Long,? extends Long> function)
replaceAll(ObjLongToLongFunction)
insteadreplaceAll
in interface Map<K,Long>
void replaceAll(@Nonnull ObjLongToLongFunction<? super K> function)
function
- the function to apply to each entryUnsupportedOperationException
- if the set
operation
is not supported by this map's entry set iteratorIllegalArgumentException
- if some property of a replacement value
prevents it from being stored in this map (optional restriction)@Nullable @Deprecated Long remove(Object key)
removeAsLong(Object)
insteadlong removeAsLong(Object key)
More formally, if this map contains a mapping from a key k
to a value v
such that keyEquivalence() == null ? (key==null ? k==null : key.equals(k)) :
keyEquivalence().nullableEquivalent(k, key)
, that mapping is removed.
(The map can contain at most one such mapping.)
Returns the value to which this map previously associated the key, or default value if the map contained no mapping for the key.
A return value of default value 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 default value.
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 default
value if there was
no mapping for key
ClassCastException
- if the class of the specified key
prevents it from being stored in this map (optional restriction)NullPointerException
- if the specified key is null,
and this map does not permit null keys (optional restriction)UnsupportedOperationException
- if the remove
operation
is not supported by this map@Deprecated boolean remove(Object key, Object value)
remove(Object, long)
insteadremove
in interface Map<K,Long>
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 value is null
, or if the specified key is null,
and this map does not permit null keys (optional restriction)ClassCastException
- if the class of the specified key
prevents it from being stored in this map (optional restriction)UnsupportedOperationException
- if the remove
operation
is not supported by this mapboolean remove(Object key, long 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 key
prevents it from being stored in this map (optional restriction)NullPointerException
- if the specified key is null,
and this map does not permit null keys (optional restriction)UnsupportedOperationException
- if the remove
operation
is not supported by this mapboolean removeIf(@Nonnull ObjLongPredicate<? super K> 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.