Class IntKeyMap<V>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<IntKeyMap.Entry<V>>

    public final class IntKeyMap<V>
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable, java.lang.Iterable<IntKeyMap.Entry<V>>
    An integer-keyed map, optimized for fast copying. Based on FastCopyHashMap by Jason T. Greene.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  IntKeyMap.Entry<V>
      A map entry.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      IntKeyMap<V> clone()  
      boolean containsKey​(int key)  
      boolean containsValue​(java.lang.Object value)  
      private static boolean eq​(java.lang.Object o1, java.lang.Object o2)  
      V get​(int key)  
      private static int index​(int hashCode, int length)  
      private void init​(int initialCapacity, float loadFactor)  
      boolean isEmpty()  
      java.util.Iterator<IntKeyMap.Entry<V>> iterator()
      Iterate over the entries.
      private int nextIndex​(int index, int length)  
      void printDebugStats()  
      V put​(int key, V value)  
      private void putForCreate​(int key, V value)  
      private void readObject​(java.io.ObjectInputStream s)  
      private void relocate​(int start)  
      V remove​(int key)  
      private void resize​(int from)  
      int size()  
      private void writeObject​(java.io.ObjectOutputStream s)  
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • DEFAULT_CAPACITY

        private static final int DEFAULT_CAPACITY
        Same default as HashMap, must be a power of 2
        See Also:
        Constant Field Values
      • MAXIMUM_CAPACITY

        private static final int MAXIMUM_CAPACITY
        MAX_INT - 1
        See Also:
        Constant Field Values
      • DEFAULT_LOAD_FACTOR

        private static final float DEFAULT_LOAD_FACTOR
        67%, just like IdentityHashMap
        See Also:
        Constant Field Values
      • size

        private transient int size
        The current number of key-value pairs
      • threshold

        private transient int threshold
        The next resize
      • loadFactor

        private final float loadFactor
        The user defined load factor which defines when to resize
    • Constructor Detail

      • IntKeyMap

        public IntKeyMap​(int initialCapacity,
                         float loadFactor)
      • IntKeyMap

        public IntKeyMap​(IntKeyMap<? extends V> map)
      • IntKeyMap

        public IntKeyMap​(int initialCapacity)
      • IntKeyMap

        public IntKeyMap()
    • Method Detail

      • init

        private void init​(int initialCapacity,
                          float loadFactor)
      • nextIndex

        private int nextIndex​(int index,
                              int length)
      • eq

        private static boolean eq​(java.lang.Object o1,
                                  java.lang.Object o2)
      • index

        private static int index​(int hashCode,
                                 int length)
      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • get

        public V get​(int key)
      • containsKey

        public boolean containsKey​(int key)
      • containsValue

        public boolean containsValue​(java.lang.Object value)
      • put

        public V put​(int key,
                     V value)
      • resize

        private void resize​(int from)
      • remove

        public V remove​(int key)
      • relocate

        private void relocate​(int start)
      • clear

        public void clear()
      • clone

        public IntKeyMap<V> clone()
        Overrides:
        clone in class java.lang.Object
      • printDebugStats

        public void printDebugStats()
      • readObject

        private void readObject​(java.io.ObjectInputStream s)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • putForCreate

        private void putForCreate​(int key,
                                  V value)
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream s)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • iterator

        public java.util.Iterator<IntKeyMap.Entry<V>> iterator()
        Iterate over the entries. Read-only operation.
        Specified by:
        iterator in interface java.lang.Iterable<V>
        Returns:
        the entry iterator