Class IndexedMap<K,​V>

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

    public class IndexedMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    implements Paired<K,​V>
    Wrap two arrays (of keys and values) and treat the result as a Map. There is no check that the supplied array of keys does not contain duplicates – the index is the real "key".
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  IndexedMap.MappedPrimitives<K>  
      • 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>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      EntrySet<K,​V> entrySet()  
      K getKey​(int index)  
      EntryPair<K,​V> getPair​(int index)  
      V getValue​(int index)  
      static <K extends java.lang.Enum<K>>
      IndexedMap.MappedPrimitives<K>
      of​(java.lang.Class<K> keyType, byte defaultValue)  
      static <K extends java.lang.Enum<K>>
      IndexedMap.MappedPrimitives<K>
      of​(java.lang.Class<K> keyType, double defaultValue)  
      static <K extends java.lang.Enum<K>>
      IndexedMap.MappedPrimitives<K>
      of​(java.lang.Class<K> keyType, float defaultValue)  
      static <K extends java.lang.Enum<K>>
      IndexedMap.MappedPrimitives<K>
      of​(java.lang.Class<K> keyType, int defaultValue)  
      static <K extends java.lang.Enum<K>>
      IndexedMap.MappedPrimitives<K>
      of​(java.lang.Class<K> keyType, long defaultValue)  
      static <K extends java.lang.Enum<K>>
      IndexedMap.MappedPrimitives<K>
      of​(java.lang.Class<K> keyType, short defaultValue)  
      static <K extends java.lang.Enum<K>,​V>
      IndexedMap<K,​V>
      of​(java.lang.Class<K> keyType, java.lang.Class<V> valueType)  
      static <K extends java.lang.Enum<K>,​V>
      IndexedMap<K,​V>
      of​(java.lang.Class<K> keyType, V defaultValue)  
      int size()  
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, 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
    • Field Detail

      • myEntrySet

        private final EntrySet<K,​V> myEntrySet
    • Constructor Detail

      • IndexedMap

        IndexedMap​(EntrySet<K,​V> entries)
    • Method Detail

      • of

        public static <K extends java.lang.Enum<K>> IndexedMap.MappedPrimitives<K> of​(java.lang.Class<K> keyType,
                                                                                      byte defaultValue)
      • of

        public static <K extends java.lang.Enum<K>,​V> IndexedMap<K,​V> of​(java.lang.Class<K> keyType,
                                                                                     java.lang.Class<V> valueType)
      • of

        public static <K extends java.lang.Enum<K>> IndexedMap.MappedPrimitives<K> of​(java.lang.Class<K> keyType,
                                                                                      double defaultValue)
      • of

        public static <K extends java.lang.Enum<K>> IndexedMap.MappedPrimitives<K> of​(java.lang.Class<K> keyType,
                                                                                      float defaultValue)
      • of

        public static <K extends java.lang.Enum<K>> IndexedMap.MappedPrimitives<K> of​(java.lang.Class<K> keyType,
                                                                                      int defaultValue)
      • of

        public static <K extends java.lang.Enum<K>> IndexedMap.MappedPrimitives<K> of​(java.lang.Class<K> keyType,
                                                                                      long defaultValue)
      • of

        public static <K extends java.lang.Enum<K>> IndexedMap.MappedPrimitives<K> of​(java.lang.Class<K> keyType,
                                                                                      short defaultValue)
      • of

        public static <K extends java.lang.Enum<K>,​V> IndexedMap<K,​V> of​(java.lang.Class<K> keyType,
                                                                                     V defaultValue)
      • entrySet

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

        public K getKey​(int index)
        Specified by:
        getKey in interface Paired<K,​V>
      • getValue

        public V getValue​(int index)
        Specified by:
        getValue in interface Paired<K,​V>
      • size

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