Class DifferentialMap<K,​V>

  • All Implemented Interfaces:
    java.util.Map<K,​V>
    Direct Known Subclasses:
    DifferentialMapAbstractState

    public class DifferentialMap<K,​V>
    extends java.lang.Object
    implements java.util.Map<K,​V>
    A differential representation of maps. Maps are stored as trees with full maps as roots and action nodes. Action nodes define either element deletion or insertion. The value of the map is defined as the root map with action nodes between it and the current node applied to it. Any action node can be used to form a root of another tree with an equivalent semantic. A predicate on when to collapse can be provided for creating root nodes automatically upon insertion or removal.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      DifferentialMap()
      Create an empty differential map.
      DifferentialMap​(java.util.Map<K,​V> m)
      Create a differential map from another map.
      DifferentialMap​(java.util.Map<K,​V> m, java.util.function.Predicate<DifferentialMap<K,​V>> shouldCollapse)
      Create a differential map from another map and a collapse criterion.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      void collapse()
      Changes the internal representation by applying action nodes to a copy of the root.
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object value)  
      @NotNull java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      boolean equals​(java.lang.Object obj)  
      V get​(java.lang.Object key)  
      int getDepth()
      Returns the depth of the action node with regard to the root map.
      int hashCode()  
      boolean isEmpty()  
      @NotNull java.util.Set<K> keySet()  
      V put​(K key, V value)  
      void putAll​(@NotNull java.util.Map<? extends K,​? extends V> m)  
      V remove​(java.lang.Object key)  
      int size()  
      @NotNull java.util.Collection<V> values()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Field Detail

      • shouldCollapse

        protected final java.util.function.Predicate<DifferentialMap<K,​V>> shouldCollapse
    • Constructor Detail

      • DifferentialMap

        public DifferentialMap()
        Create an empty differential map.
      • DifferentialMap

        public DifferentialMap​(java.util.Map<K,​V> m)
        Create a differential map from another map.
        Parameters:
        m - initial map if it is a differential map, the collapse criterion will be copied from it
      • DifferentialMap

        public DifferentialMap​(java.util.Map<K,​V> m,
                               java.util.function.Predicate<DifferentialMap<K,​V>> shouldCollapse)
        Create a differential map from another map and a collapse criterion.
        Parameters:
        m - initial map
        shouldCollapse - whether the map should collapse into a root node
    • Method Detail

      • collapse

        public void collapse()
        Changes the internal representation by applying action nodes to a copy of the root.
      • getDepth

        public int getDepth()
        Returns the depth of the action node with regard to the root map.
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<K,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
      • put

        @Nullable
        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
      • putAll

        public void putAll​(@NotNull
                           @NotNull java.util.Map<? extends K,​? extends V> m)
        Specified by:
        putAll in interface java.util.Map<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
      • keySet

        @NotNull
        public @NotNull java.util.Set<K> keySet()
        Specified by:
        keySet in interface java.util.Map<K,​V>
      • values

        @NotNull
        public @NotNull java.util.Collection<V> values()
        Specified by:
        values in interface java.util.Map<K,​V>
      • entrySet

        @NotNull
        public @NotNull java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map<K,​V>
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Map<K,​V>
        Overrides:
        equals in class java.lang.Object