Class ArrayMap<K,​V>

  • Type Parameters:
    K - Key type
    V - Value type
    All Implemented Interfaces:

    public class ArrayMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    Simple ArrayList backed Map implementation which uses simple linear scans of the list for searching for matching keys. Ideal for very small maps where the cost of hash computation may be considered excessive and Object.equals(Object) of the key is cheap. Permits null as a key value.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • 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

      Modifier and Type Field Description
      protected java.util.ArrayList<java.util.Map.Entry<K,​V>> _entries  
    • Constructor Summary

      Constructor Description
      ArrayMap​(int initialSize)  
      ArrayMap​(int initialSize, java.util.function.BiPredicate<K,​K> keyEquals)  
      ArrayMap​(java.util.function.BiPredicate<K,​K> keyEquals)  
      ArrayMap​(java.util.Map<K,​V> source)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
      boolean keyEquals​(K a, K b)  
      V put​(K key, V value)
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
      • Methods inherited from class java.lang.Object

        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

      • _entries

        protected final java.util.ArrayList<java.util.Map.Entry<K,​V>> _entries
    • Constructor Detail

      • ArrayMap

        public ArrayMap()
      • ArrayMap

        public ArrayMap​(java.util.function.BiPredicate<K,​K> keyEquals)
      • ArrayMap

        public ArrayMap​(int initialSize)
      • ArrayMap

        public ArrayMap​(int initialSize,
                        java.util.function.BiPredicate<K,​K> keyEquals)
      • ArrayMap

        public ArrayMap​(java.util.Map<K,​V> source)
    • Method Detail

      • keyEquals

        public final boolean keyEquals​(K a,
                                       K b)
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        put in class java.util.AbstractMap<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>