Class EconomicMapWrap<K,V>

java.lang.Object
org.graalvm.collections.EconomicMapWrap<K,V>
All Implemented Interfaces:
EconomicMap<K,V>, UnmodifiableEconomicMap<K,V>

public class EconomicMapWrap<K,V> extends Object implements EconomicMap<K,V>
Wraps an existing Map as an EconomicMap.
Since:
21.1
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all of the mappings from this map.
    boolean
    Returns true if this map contains a mapping for key.
    get(K key)
    Returns the value to which key is mapped, or null if this map contains no mapping for key.
    Returns a MapCursor view of the mappings contained in this map.
    Returns a Iterable view of the keys contained in this map.
    Returns a Iterable view of the values contained in this map.
    boolean
    Returns true if this map contains no key-value mappings.
    put(K key, V value)
    Associates value with key in this map.
    putIfAbsent(K 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.
    removeKey(K key)
    Removes the mapping for key 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 invoking function on that entry until all entries have been processed or the function throws an exception.
    int
    Returns the number of key-value mappings in this map.
     

    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

      public EconomicMapWrap(Map<K,V> map)
      Since:
      21.1
  • Method Details

    • get

      public V get(K key)
      Description copied from interface: UnmodifiableEconomicMap
      Returns the value to which key is mapped, or null if this map contains no mapping for key. The key must not be null.
      Specified by:
      get in interface UnmodifiableEconomicMap<K,V>
      Since:
      21.1
    • put

      public V put(K key, V value)
      Description copied from interface: EconomicMap
      Associates value with key in this map. If the map previously contained a mapping for key, the old value is replaced by value. While the value may be null, the key must not be {code null}.
      Specified by:
      put in interface EconomicMap<K,V>
      Returns:
      the previous value associated with key, or null if there was no mapping for key.
      Since:
      21.1
    • putIfAbsent

      public V putIfAbsent(K key, V value)
      Description copied from interface: EconomicMap
      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.
      Specified by:
      putIfAbsent in interface EconomicMap<K,V>
      Parameters:
      key - key with which the specified value is to be associated
      value - 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. (A null return can also indicate that the map previously associated null 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 interface UnmodifiableEconomicMap<K,V>
      Since:
      21.1
    • containsKey

      public boolean containsKey(K key)
      Description copied from interface: UnmodifiableEconomicMap
      Returns true if this map contains a mapping for key. Always returns false if the key is null.
      Specified by:
      containsKey in interface UnmodifiableEconomicMap<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 interface EconomicMap<K,V>
      Since:
      21.1
    • removeKey

      public V removeKey(K key)
      Description copied from interface: EconomicMap
      Removes the mapping for key from this map if it is present. The map will not contain a mapping for key once the call returns. The key must not be null.
      Specified by:
      removeKey in interface EconomicMap<K,V>
      Returns:
      the previous value associated with key, or null if there was no mapping for key.
      Since:
      21.1
    • getValues

      public Iterable<V> getValues()
      Description copied from interface: UnmodifiableEconomicMap
      Returns a Iterable view of the values contained in this map.
      Specified by:
      getValues in interface UnmodifiableEconomicMap<K,V>
      Since:
      21.1
    • getKeys

      public Iterable<K> getKeys()
      Description copied from interface: UnmodifiableEconomicMap
      Returns a Iterable view of the keys contained in this map.
      Specified by:
      getKeys in interface UnmodifiableEconomicMap<K,V>
      Since:
      21.1
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: UnmodifiableEconomicMap
      Returns true if this map contains no key-value mappings.
      Specified by:
      isEmpty in interface UnmodifiableEconomicMap<K,V>
      Since:
      21.1
    • getEntries

      public MapCursor<K,V> getEntries()
      Description copied from interface: EconomicMap
      Returns a MapCursor view of the mappings contained in this map.
      Specified by:
      getEntries in interface EconomicMap<K,V>
      Specified by:
      getEntries in interface UnmodifiableEconomicMap<K,V>
      Since:
      21.1
    • replaceAll

      public void replaceAll(BiFunction<? super K,? super V,? extends V> function)
      Description copied from interface: EconomicMap
      Replaces each entry's value with the result of invoking function 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 interface EconomicMap<K,V>
      Since:
      21.1
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      23.1