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.
      Specified by:
      size in interface Map<K,V>
      Returns:
      the number of mappings in this Map.
    • isEmpty

      public boolean isEmpty()
      Returns whether this map is empty.
      Specified by:
      isEmpty in interface Map<K,V>
      Returns:
      true if this map has no elements, false otherwise.
      See Also:
    • containsKey

      public boolean containsKey(Object key)
      Returns whether this Map contains the specified key.
      Specified by:
      containsKey in interface Map<K,V>
      Parameters:
      key - the key to search for.
      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>
      Parameters:
      value - the value to search for.
      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.
      Specified by:
      get in interface Map<K,V>
      Parameters:
      key - the key.
      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.
      Specified by:
      put in interface Map<K,V>
      Parameters:
      key - the key.
      value - the value.
      Returns:
      the value of any previous mapping with the specified key or null if there was no mapping.
    • remove

      public V remove(Object key)
      Removes a mapping with the specified key from this Map.
      Specified by:
      remove in interface Map<K,V>
      Parameters:
      key - the key of the mapping to remove.
      Returns:
      the value of the removed mapping or null if no mapping for the specified key was found.
    • putAll

      public void putAll(Map<? extends K, ? extends V> m)
      Copies every mapping in the specified Map to this Map.
      Specified by:
      putAll in interface Map<K,V>
      Parameters:
      m - the Map to copy mappings from.
    • clear

      public void clear()
      Removes all elements from this Map, leaving it empty.
      Specified by:
      clear in interface Map<K,V>
      See Also:
    • 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.
      Specified by:
      keySet in interface Map<K,V>
      Returns:
      a set of the keys.
    • values

      public Collection<V> values()
      Unsupported operation
      Specified by:
      values in interface Map<K,V>
      Returns:
      a collection of the values contained in this map.
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Unsupported operation
      Specified by:
      entrySet in interface Map<K,V>
      Returns:
      a set of the mappings