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>
    Modifier and Type
    Interface
    Description
    static interface 
    Map.Entry is a key/value mapping contained in a Map.
  • 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
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

    Methods inherited from interface Map

    equals, hashCode
    Modifier and Type
    Method
    Description
    boolean
    equals(Object object)
    Compares the argument to the receiver, and returns true if the specified object is a Map and both Maps contain the same mappings.
    int
    Returns an integer hash code for the receiver.
  • 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