Package ghidra.util.datastruct

# Class AbstractWeakValueMap<K,V>

java.lang.Object
ghidra.util.datastruct.AbstractWeakValueMap<K,V>

Type Parameters:
  `K` - the type of keys
  `V` - the type of values

All Implemented Interfaces:
  `Map<K,V>`

Direct Known Subclasses:
  `AbstractWeakValueNavigableMap`, `CopyOnWrite.WeakValueAbstractCowMap`, `WeakValueHashMap`

public abstract class AbstractWeakValueMap<K,V> extends Object implements Map<K,V>
Class to provide a map with weak values, backed by a given map

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected class`
  `AbstractWeakValueMap.GeneratedEntry`
  An entry for the "entrySet" method, since internally, entries are of weak-referenced values.
  `protected static class`
  `AbstractWeakValueMap.WeakValueRef<K,V>`
  A weak value ref that also knows its key in the map.

  ## Nested classes/interfaces inherited from interface java.util.Map

  `Map.Entry<K,V>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected ReferenceQueue<V>`
  `refQueue`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractWeakValueMap()`
  Constructs a new weak map

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  `boolean`
  `containsKey(Object key)`
  `boolean`
  `containsValue(Object value)`
  `Set<Map.Entry<K,V>>`
  `entrySet()`
  `V`
  `get(Object key)`
  `protected abstract Map<K,AbstractWeakValueMap.WeakValueRef<K,V>>`
  `getRefMap()`
  Returns the backing map
  `boolean`
  `isEmpty()`
  `Set<K>`
  `keySet()`
  `protected void`
  `processQueue()`
  `V`
  `put(K key, V value)`
  `void`
  `putAll(Map<? extends K,? extends V> map)`
  `V`
  `remove(Object key)`
  `int`
  `size()`
  `Collection<V>`
  `values()`
  Returns a `Collection` view of the values contained in this map.

  ### Methods inherited from class java.lang.Object

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

  ### Methods inherited from interface java.util.Map

  `compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll`

- ## Field Details

  - ### refQueue

    protected ReferenceQueue<V> refQueue

- ## Constructor Details

  - ### AbstractWeakValueMap

    protected AbstractWeakValueMap()
    Constructs a new weak map

- ## Method Details

  - ### getRefMap

    protected abstract Map<K,AbstractWeakValueMap.WeakValueRef<K,V>> getRefMap()
    Returns the backing map
    Returns:
      the map

  - ### put

    public V put(K key, V value)
    Specified by:
      `put` in interface `Map<K,V>`

  - ### get

    public V get(Object key)
    Specified by:
      `get` in interface `Map<K,V>`

  - ### size

    public int size()
    Specified by:
      `size` in interface `Map<K,V>`

  - ### clear

    public void clear()
    Specified by:
      `clear` in interface `Map<K,V>`

  - ### isEmpty

    public boolean isEmpty()
    Specified by:
      `isEmpty` in interface `Map<K,V>`

  - ### containsKey

    public boolean containsKey(Object key)
    Specified by:
      `containsKey` in interface `Map<K,V>`

  - ### containsValue

    public boolean containsValue(Object value)
    Specified by:
      `containsValue` in interface `Map<K,V>`

  - ### values

    public Collection<V> values()
    Returns a `Collection` view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. However, since values in this map are held via weak references, the collection returned is effectively weak in that any time, values may disappear from the collection. To get a static view of the values in this map, you should construct another collection class (List, Set, etc.) and pass this collection to it in its constructor.
    Specified by:
      `values` in interface `Map<K,V>`

  - ### putAll

    public void putAll(Map<? extends K,? extends V> map)
    Specified by:
      `putAll` in interface `Map<K,V>`

  - ### entrySet

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

  - ### keySet

    public Set<K> keySet()
    Specified by:
      `keySet` in interface `Map<K,V>`

  - ### remove

    public V remove(Object key)
    Specified by:
      `remove` in interface `Map<K,V>`

  - ### processQueue

    protected void processQueue()