Class DirtyFlagMap<K,​V>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<K,​V>
    Direct Known Subclasses:
    StringKeyDirtyFlagMap

    public class DirtyFlagMap<K,​V>
    extends java.lang.Object
    implements java.util.Map<K,​V>, java.lang.Cloneable, java.io.Serializable

    An implementation of Map that wraps another Map and flags itself 'dirty' when it is modified.

    Author:
    James House
    See Also:
    Serialized Form
    • 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
      DirtyFlagMap()
      Create a DirtyFlagMap that 'wraps' a HashMap.
      DirtyFlagMap​(int initialCapacity)
      Create a DirtyFlagMap that 'wraps' a HashMap that has the given initial capacity.
      DirtyFlagMap​(int initialCapacity, float loadFactor)
      Create a DirtyFlagMap that 'wraps' a HashMap that has the given initial capacity and load factor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      void clearDirtyFlag()
      Clear the 'dirty' flag (set dirty flag to false).
      java.lang.Object clone()  
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object val)  
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      boolean equals​(java.lang.Object obj)  
      V get​(java.lang.Object key)  
      java.util.Map<K,​V> getWrappedMap()
      Get a direct handle to the underlying Map.
      int hashCode()  
      boolean isDirty()
      Determine whether the Map is flagged dirty.
      boolean isEmpty()  
      java.util.Set<K> keySet()  
      V put​(K key, V val)  
      void putAll​(java.util.Map<? extends K,​? extends V> t)  
      V remove​(java.lang.Object key)  
      int size()  
      java.util.Collection<V> values()  
      • Methods inherited from class java.lang.Object

        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
    • Constructor Detail

      • DirtyFlagMap

        public DirtyFlagMap()

        Create a DirtyFlagMap that 'wraps' a HashMap.

        See Also:
        HashMap
      • DirtyFlagMap

        public DirtyFlagMap​(int initialCapacity)

        Create a DirtyFlagMap that 'wraps' a HashMap that has the given initial capacity.

        See Also:
        HashMap
      • DirtyFlagMap

        public DirtyFlagMap​(int initialCapacity,
                            float loadFactor)

        Create a DirtyFlagMap that 'wraps' a HashMap that has the given initial capacity and load factor.

        See Also:
        HashMap
    • Method Detail

      • clearDirtyFlag

        public void clearDirtyFlag()

        Clear the 'dirty' flag (set dirty flag to false).

      • isDirty

        public boolean isDirty()

        Determine whether the Map is flagged dirty.

      • getWrappedMap

        public java.util.Map<K,​V> getWrappedMap()

        Get a direct handle to the underlying Map.

      • clear

        public void clear()
        Specified by:
        clear 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 val)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
      • 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
      • hashCode

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

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

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

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

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

        public void putAll​(java.util.Map<? extends K,​? extends V> t)
        Specified by:
        putAll 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>
      • size

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

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

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object