Class WeakValueConcurrentHashMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
net.solarnetwork.util.WeakValueConcurrentHashMap<K,V>
All Implemented Interfaces:
ConcurrentMap<K,V>, Map<K,V>

public class WeakValueConcurrentHashMap<K,V> extends AbstractMap<K,V> implements ConcurrentMap<K,V>
A ConcurrentMap implementation with weak-referenced values.

The values stored in this map are only weakly-referenced. If a value is garbage collected, then the associated key will remain in this map, but methods that query for the value based on its key will return null.

Version:
1.0
Author:
matt
  • Constructor Details

    • WeakValueConcurrentHashMap

      public WeakValueConcurrentHashMap()
      Creates a new, empty map with the default initial table size (16).
    • WeakValueConcurrentHashMap

      public WeakValueConcurrentHashMap(int initialCapacity)
      Creates a new, empty map with an initial table size accommodating the specified number of elements without the need to dynamically resize.
      Parameters:
      initialCapacity - The implementation performs internal sizing to accommodate this many elements.
      Throws:
      IllegalArgumentException - if the initial capacity of elements is negative
    • WeakValueConcurrentHashMap

      public WeakValueConcurrentHashMap(Map<? extends K,? extends V> m)
      Creates a new map with the same mappings as the given map.
      Parameters:
      m - the map
    • WeakValueConcurrentHashMap

      public WeakValueConcurrentHashMap(int initialCapacity, float loadFactor)
      Creates a new, empty map with an initial table size based on the given number of elements (initialCapacity) and initial table density (loadFactor).
      Parameters:
      initialCapacity - the initial capacity. The implementation performs internal sizing to accommodate this many elements, given the specified load factor.
      loadFactor - the load factor (table density) for establishing the initial table size
      Throws:
      IllegalArgumentException - if the initial capacity of elements is negative or the load factor is nonpositive
      Since:
      1.6
    • WeakValueConcurrentHashMap

      public WeakValueConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel)
      Creates a new, empty map with an initial table size based on the given number of elements (initialCapacity), table density (loadFactor), and number of concurrently updating threads (concurrencyLevel).
      Parameters:
      initialCapacity - the initial capacity. The implementation performs internal sizing to accommodate this many elements, given the specified load factor.
      loadFactor - the load factor (table density) for establishing the initial table size
      concurrencyLevel - the estimated number of concurrently updating threads. The implementation may use this value as a sizing hint.
      Throws:
      IllegalArgumentException - if the initial capacity is negative or the load factor or concurrencyLevel are nonpositive
  • Method Details