Class SmallMap

  • All Implemented Interfaces:
    java.io.Serializable, java.util.Map

    public class SmallMap
    extends java.util.AbstractMap
    implements java.io.Serializable
    Lightweight implementation of Map which uses little memory to store a small number of mappings, at the expense of scalability. Not recommended for more than 20-30 mappings.

    This implementation has the useful property that the iteration order is the same as the order in which mappings are added.

    Author:
    Thomas Down, Len Trigg
    See Also:
    Serialized Form
    • 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>
    • Constructor Summary

      Constructors 
      Constructor Description
      SmallMap()  
      SmallMap​(int size)  
      SmallMap​(java.util.Map m)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(java.lang.Object key)  
      java.util.Set entrySet()  
      java.lang.Object get​(java.lang.Object key)  
      java.util.Set keySet()  
      java.lang.Object put​(java.lang.Object key, java.lang.Object value)  
      int size()  
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsValue, equals, hashCode, isEmpty, putAll, remove, 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
    • Method Detail

      • get

        public java.lang.Object get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map
        Overrides:
        get in class java.util.AbstractMap
        Throws:
        java.lang.NullPointerException - if key is null
      • put

        public java.lang.Object put​(java.lang.Object key,
                                    java.lang.Object value)
        Specified by:
        put in interface java.util.Map
        Overrides:
        put in class java.util.AbstractMap
        Throws:
        java.lang.NullPointerException - if key is null
      • keySet

        public java.util.Set keySet()
        Specified by:
        keySet in interface java.util.Map
        Overrides:
        keySet in class java.util.AbstractMap
      • entrySet

        public java.util.Set entrySet()
        Specified by:
        entrySet in interface java.util.Map
        Specified by:
        entrySet in class java.util.AbstractMap
      • size

        public int size()
        Specified by:
        size in interface java.util.Map
        Overrides:
        size in class java.util.AbstractMap
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map
        Overrides:
        containsKey in class java.util.AbstractMap