Class WeakHashMap<K,V>

java.lang.Object
com.codename1.ui.util.WeakHashMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class WeakHashMap<K,V> extends Object implements Map<K,V>
Helper weak hash map substitute
  • Nested Class Summary

    Nested classes/interfaces inherited from interface Map

    Map.Entry<K,V>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all elements from this Map, leaving it empty.
    boolean
    Returns whether this Map contains the specified key.
    boolean
    This method is unsupported in the weak hash map
    Unsupported operation
    get(Object key)
    Returns the value of the mapping with the specified key.
    boolean
    Returns whether this map is empty.
    Returns a set of the keys contained in this Map.
    put(K key, V value)
    Maps the specified key to the specified value.
    void
    putAll(Map<? extends K, ? extends V> m)
    Copies every mapping in the specified Map to this Map.
    Removes a mapping with the specified key from this Map.
    int
    Returns the number of mappings in this Map.
    Unsupported operation

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Map

    equals, hashCode
  • Constructor Details

    • WeakHashMap

      public WeakHashMap()
  • Method Details

    • size

      public int size()

      Returns the number of mappings in this Map.

      Returns

      the number of mappings in this Map.

      Specified by:
      size in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()

      Returns whether this map is empty.

      Returns
      Specified by:
      isEmpty in interface Map<K,V>
      Returns:

      true if this map has no elements, false otherwise.

      See also
      • #size()
    • containsKey

      public boolean containsKey(Object key)

      Returns whether this Map contains the specified key.

      Parameters
      • key: the key to search for.
      Returns
      Specified by:
      containsKey in interface Map<K,V>
      Returns:
      true if this map contains the specified key, false otherwise.
    • containsValue

      public boolean containsValue(Object value)
      This method is unsupported in the weak hash map
      Specified by:
      containsValue in interface Map<K,V>
      Returns:
      true if this map contains the specified value, false otherwise.
    • get

      public V get(Object key)

      Returns the value of the mapping with the specified key.

      Parameters
      • key: the key.
      Returns
      Specified by:
      get in interface Map<K,V>
      Returns:
      the value of the mapping with the specified key, or null if no mapping for the specified key is found.
    • put

      public V put(K key, V value)

      Maps the specified key to the specified value.

      Parameters
      • key: the key.

      • value: the value.

      Returns
      Specified by:
      put in interface Map<K,V>
      Returns:

      the value of any previous mapping with the specified key or null if there was no mapping.

      Throws
      • UnsupportedOperationException: if adding to this Map is not supported.

      • ClassCastException: @throws ClassCastException if the class of the key or value is inappropriate for this Map.

      • IllegalArgumentException: if the key or value cannot be added to this Map.

      • NullPointerException: @throws NullPointerException if the key or value is null and this Map does not support null keys or values.

    • remove

      public V remove(Object key)

      Removes a mapping with the specified key from this Map.

      Parameters
      • key: the key of the mapping to remove.
      Returns
      Specified by:
      remove in interface Map<K,V>
      Returns:

      the value of the removed mapping or null if no mapping for the specified key was found.

      Throws
      • UnsupportedOperationException: if removing from this Map is not supported.
    • putAll

      public void putAll(Map<? extends K, ? extends V> m)

      Copies every mapping in the specified Map to this Map.

      Parameters
      • map: the Map to copy mappings from.
      Throws
      • UnsupportedOperationException: if adding to this Map is not supported.

      • ClassCastException: @throws ClassCastException if the class of a key or a value of the specified Map is inappropriate for this Map.

      • IllegalArgumentException: if a key or value cannot be added to this Map.

      • NullPointerException: @throws NullPointerException if a key or value is null and this Map does not support null keys or values.

      Specified by:
      putAll in interface Map<K,V>
    • clear

      public void clear()

      Removes all elements from this Map, leaving it empty.

      Throws
      • UnsupportedOperationException: if removing elements from this Map is not supported.
      See also
      • #isEmpty()

      • #size()

      Specified by:
      clear in interface Map<K,V>
    • keySet

      public Set<K> keySet()

      Returns a set of the keys contained in this Map. The Set is backed by this Map so changes to one are reflected by the other. The Set does not support adding.

      Returns

      a set of the keys.

      Specified by:
      keySet in interface Map<K,V>
    • values

      public Collection<V> values()
      Unsupported operation
      Specified by:
      values in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Unsupported operation
      Specified by:
      entrySet in interface Map<K,V>