Package org.graalvm.collections
Class EconomicMapWrap<K,V>
java.lang.Object
org.graalvm.collections.EconomicMapWrap<K,V>
- All Implemented Interfaces:
EconomicMap<K,
,V> UnmodifiableEconomicMap<K,
V>
Wraps an existing
Map
as an EconomicMap
.- Since:
- 21.1
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all of the mappings from this map.boolean
containsKey
(K key) Returnstrue
if this map contains a mapping forkey
.Returns the value to whichkey
is mapped, ornull
if this map contains no mapping forkey
.Returns aMapCursor
view of the mappings contained in this map.getKeys()
Returns aIterable
view of the keys contained in this map.Returns aIterable
view of the values contained in this map.boolean
isEmpty()
Returnstrue
if this map contains no key-value mappings.Associatesvalue
withkey
in this map.putIfAbsent
(K key, V value) If the specified key is not already associated with a value (or is mapped tonull
) associates it with the given value and returnsnull
, else returns the current value.Removes the mapping forkey
from this map if it is present.void
replaceAll
(BiFunction<? super K, ? super V, ? extends V> function) Replaces each entry's value with the result of invokingfunction
on that entry until all entries have been processed or the function throws an exception.int
size()
Returns the number of key-value mappings in this map.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.graalvm.collections.EconomicMap
putAll, putAll
Methods inherited from interface org.graalvm.collections.UnmodifiableEconomicMap
get, getEquivalenceStrategy
-
Constructor Details
-
EconomicMapWrap
- Since:
- 21.1
-
-
Method Details
-
get
Description copied from interface:UnmodifiableEconomicMap
Returns the value to whichkey
is mapped, ornull
if this map contains no mapping forkey
. Thekey
must not benull
.- Specified by:
get
in interfaceUnmodifiableEconomicMap<K,
V> - Since:
- 21.1
-
put
Description copied from interface:EconomicMap
Associatesvalue
withkey
in this map. If the map previously contained a mapping forkey
, the old value is replaced byvalue
. While thevalue
may benull
, thekey
must not be {code null}.- Specified by:
put
in interfaceEconomicMap<K,
V> - Returns:
- the previous value associated with
key
, ornull
if there was no mapping forkey
. - Since:
- 21.1
-
putIfAbsent
Description copied from interface:EconomicMap
If the specified key is not already associated with a value (or is mapped tonull
) associates it with the given value and returnsnull
, else returns the current value.- Specified by:
putIfAbsent
in interfaceEconomicMap<K,
V> - Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- Returns:
- the previous value associated with the specified key, or
null
if there was no mapping for the key. (Anull
return can also indicate that the map previously associatednull
with the key, if the implementation supports null values.) - Since:
- 21.1
-
size
public int size()Description copied from interface:UnmodifiableEconomicMap
Returns the number of key-value mappings in this map.- Specified by:
size
in interfaceUnmodifiableEconomicMap<K,
V> - Since:
- 21.1
-
containsKey
Description copied from interface:UnmodifiableEconomicMap
Returnstrue
if this map contains a mapping forkey
. Always returnsfalse
if thekey
isnull
.- Specified by:
containsKey
in interfaceUnmodifiableEconomicMap<K,
V> - Since:
- 21.1
-
clear
public void clear()Description copied from interface:EconomicMap
Removes all of the mappings from this map. The map will be empty after this call returns.- Specified by:
clear
in interfaceEconomicMap<K,
V> - Since:
- 21.1
-
removeKey
Description copied from interface:EconomicMap
Removes the mapping forkey
from this map if it is present. The map will not contain a mapping forkey
once the call returns. Thekey
must not benull
.- Specified by:
removeKey
in interfaceEconomicMap<K,
V> - Returns:
- the previous value associated with
key
, ornull
if there was no mapping forkey
. - Since:
- 21.1
-
getValues
Description copied from interface:UnmodifiableEconomicMap
Returns aIterable
view of the values contained in this map.- Specified by:
getValues
in interfaceUnmodifiableEconomicMap<K,
V> - Since:
- 21.1
-
getKeys
Description copied from interface:UnmodifiableEconomicMap
Returns aIterable
view of the keys contained in this map.- Specified by:
getKeys
in interfaceUnmodifiableEconomicMap<K,
V> - Since:
- 21.1
-
isEmpty
public boolean isEmpty()Description copied from interface:UnmodifiableEconomicMap
Returnstrue
if this map contains no key-value mappings.- Specified by:
isEmpty
in interfaceUnmodifiableEconomicMap<K,
V> - Since:
- 21.1
-
getEntries
Description copied from interface:EconomicMap
Returns aMapCursor
view of the mappings contained in this map.- Specified by:
getEntries
in interfaceEconomicMap<K,
V> - Specified by:
getEntries
in interfaceUnmodifiableEconomicMap<K,
V> - Since:
- 21.1
-
replaceAll
Description copied from interface:EconomicMap
Replaces each entry's value with the result of invokingfunction
on that entry until all entries have been processed or the function throws an exception. Exceptions thrown by the function are relayed to the caller.- Specified by:
replaceAll
in interfaceEconomicMap<K,
V> - Since:
- 21.1
-
toString
-