Class CopyOnWriteHashMap<K,​V>

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

    public class CopyOnWriteHashMap<K,​V>
    extends AbstractMap<K,​V>
    implements Cloneable
    A hashmap wrapper which defers cloning of the enclosed map until it is written to. Use this to make clones cheap in maps which are often not further modified.

    As with regular maps, this can only be used safely if the content of the map is immutable. If not, the copyMap(java.util.Map<K, V>) method can be overridden to perform a deep clone.

    Author:
    bratseth
    • Constructor Detail

      • CopyOnWriteHashMap

        public CopyOnWriteHashMap()
      • CopyOnWriteHashMap

        public CopyOnWriteHashMap​(int capacity)
      • CopyOnWriteHashMap

        public CopyOnWriteHashMap​(Map<K,​V> map)