Class MapUtil


  • public final class MapUtil
    extends java.lang.Object
    Utility methods for working with Maps.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      java.util.HashMap<K,​V>
      newHashMapWithExpectedSize​(int expectedSize)
      Creates a HashMap with enough capacity to hold the expected number of entries without resizing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • newHashMapWithExpectedSize

        public static <K,​V> java.util.HashMap<K,​V> newHashMapWithExpectedSize​(int expectedSize)
        Creates a HashMap with enough capacity to hold the expected number of entries without resizing. This is equivalent to Guava's Maps.newHashMapWithExpectedSize().
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        expectedSize - the expected number of entries
        Returns:
        a new HashMap with appropriate initial capacity