Class FastCopyHashMap<K,​V>

  • All Implemented Interfaces:
    Serializable, Cloneable, Map<K,​V>

    public 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.

    Author:
    Jason T. Greene
    See Also:
    Serialized Form