Class FastCopyHashMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
org.jboss.logmanager.FastCopyHashMap<K,V>
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>

class FastCopyHashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable
A HashMap that is optimized for fast shallow copies. If the copy-ctor is passed another FastCopyHashMap, or clone is called on this map, the shallow copy can be performed using little more than a single array copy. In order to accomplish this, immutable objects must be used internally, so update operations result in slightly more object churn than HashMap. Note: It is very important to use a smaller load factor than you normally would for HashMap, since the implementation is open-addressed with linear probing. With a 50% load-factor a get is expected to return in only 2 probes. However, a 90% load-factor is expected to return in around 50 probes.
  • Field Details

    • NULL

      private static final Object NULL
      Marks null keys.
    • serialVersionUID

      private static final long serialVersionUID
      Serialization ID
      See Also:
    • DEFAULT_CAPACITY

      private static final int DEFAULT_CAPACITY
      Same default as HashMap, must be a power of 2
      See Also:
    • MAXIMUM_CAPACITY

      private static final int MAXIMUM_CAPACITY
      MAX_INT - 1
      See Also:
    • DEFAULT_LOAD_FACTOR

      private static final float DEFAULT_LOAD_FACTOR
      67%, just like IdentityHashMap
      See Also:
    • table

      private transient FastCopyHashMap.Entry<K,V>[] table
      The open-addressed table
    • size

      private transient int size
      The current number of key-value pairs
    • threshold

      private transient int threshold
      The next resize
    • loadFactor

      private final float loadFactor
      The user defined load factor which defines when to resize
    • modCount

      private transient int modCount
      Counter used to detect changes made outside of an iterator
    • keySet

      private transient FastCopyHashMap<K,V>.KeySet keySet
    • values

      private transient FastCopyHashMap<K,V>.Values values
    • entrySet

      private transient FastCopyHashMap<K,V>.EntrySet entrySet
  • Constructor Details

    • FastCopyHashMap

      public FastCopyHashMap(int initialCapacity, float loadFactor)
    • FastCopyHashMap

      public FastCopyHashMap(Map<? extends K,? extends V> map)
    • FastCopyHashMap

      public FastCopyHashMap(int initialCapacity)
    • FastCopyHashMap

      public FastCopyHashMap()
  • Method Details