Class SnapshotMap<K,​V>


  • public class SnapshotMap<K,​V>
    extends java.lang.Object
    A snapshotable map.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.concurrent.locks.ReentrantReadWriteLock lock  
      (package private) java.util.NavigableMap<K,​V> snapshot  
      (package private) java.util.Map<K,​V> updates  
      (package private) java.util.Map<K,​V> updatesToMerge  
    • Constructor Summary

      Constructors 
      Constructor Description
      SnapshotMap()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(K key)
      Returns true if this map contains a mapping for the specified key.
      void put​(K key, V value)
      Associates the specified value with the specified key in this map.
      void remove​(K key)
      Removes the mapping for the key from this map if it is present.
      java.util.NavigableMap<K,​V> snapshot()
      Create a snapshot of current map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • updates

        volatile java.util.Map<K,​V> updates
      • updatesToMerge

        volatile java.util.Map<K,​V> updatesToMerge
      • snapshot

        volatile java.util.NavigableMap<K,​V> snapshot
      • lock

        final java.util.concurrent.locks.ReentrantReadWriteLock lock
    • Constructor Detail

      • SnapshotMap

        public SnapshotMap()
    • Method Detail

      • snapshot

        public java.util.NavigableMap<K,​V> snapshot()
        Create a snapshot of current map.
        Returns:
        a snapshot of current map.
      • put

        public void put​(K key,
                        V value)
        Associates the specified value with the specified key in this map.
        Parameters:
        key - Key with which the specified value is to be associated.
        value - Value to be associated with the specified key.
      • remove

        public void remove​(K key)
        Removes the mapping for the key from this map if it is present.
        Parameters:
        key - Key whose mapping is to be removed from this map.
      • containsKey

        public boolean containsKey​(K key)
        Returns true if this map contains a mapping for the specified key.
        Parameters:
        key - Key whose presence is in the map to be tested.
        Returns:
        true if the map contains a mapping for the specified key.