Class KeyCollectionAsMap<K,​E>

  • All Implemented Interfaces:
    java.io.Serializable, java.util.Map<K,​E>

    public class KeyCollectionAsMap<K,​E>
    extends java.lang.Object
    implements java.util.Map<K,​E>, java.io.Serializable
    Implements a Map based on a key map in a KeyCollection or KeyList.
    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>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) KeyCollectionImpl<E> coll
      Reference to KeyCollectionImpl containing data (exactly one of the fields coll and list is set)
      (package private) boolean immutable  
      (package private) int keyIndex  
      (package private) KeyListImpl<E> list
      Reference to KeyListImpl containing data (exactly one of the fields coll and list is set)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void checkMutable()  
      void clear()  
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object value)  
      java.util.Set<java.util.Map.Entry<K,​E>> entrySet()
      boolean equals​(java.lang.Object o)  
      E get​(java.lang.Object key)  
      int hashCode()  
      boolean isEmpty()  
      java.util.Set<K> keySet()
      E put​(K key, E elem)  
      void putAll​(java.util.Map<? extends K,​? extends E> map)  
      E remove​(java.lang.Object key)  
      int size()  
      java.lang.String toString()  
      java.util.Collection<E> values()  
      • Methods inherited from class java.lang.Object

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

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

      • coll

        KeyCollectionImpl<E> coll
        Reference to KeyCollectionImpl containing data (exactly one of the fields coll and list is set)
      • list

        KeyListImpl<E> list
        Reference to KeyListImpl containing data (exactly one of the fields coll and list is set)
      • keyIndex

        int keyIndex
      • immutable

        boolean immutable
    • Constructor Detail

      • KeyCollectionAsMap

        public KeyCollectionAsMap​(KeyCollectionImpl<E> coll,
                                  int keyIndex,
                                  boolean immutable)
      • KeyCollectionAsMap

        public KeyCollectionAsMap​(KeyListImpl<E> list,
                                  int keyIndex,
                                  boolean immutable)
    • Method Detail

      • equals

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

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • size

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

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

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

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

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

        public java.util.Set<K> keySet()

        Note that the returned set is immutable.

        Specified by:
        keySet in interface java.util.Map<K,​E>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​E>> entrySet()

        Note that the returned set is immutable.

        Specified by:
        entrySet in interface java.util.Map<K,​E>
      • values

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

        void checkMutable()
      • clear

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

        public E put​(K key,
                     E elem)
        Specified by:
        put in interface java.util.Map<K,​E>
      • remove

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

        public void putAll​(java.util.Map<? extends K,​? extends E> map)
        Specified by:
        putAll in interface java.util.Map<K,​E>