com.hazelcast.util

## Class MapUtil

- java.lang.Object
- - com.hazelcast.util.MapUtil

-     public final class MapUtil
      extends Object

  Utility class for Maps

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `calculateInitialCapacity(int expectedMapSize)` Returns the initial hash map capacity needed for the expected map size.
    `static <K,V> ConcurrentMap<K,V>` | `createConcurrentHashMap(int expectedMapSize)` Utility method that creates an `LinkedHashMap` with its initialCapacity calculated to minimize rehash operations
    `static <K,V> Map<K,V>` | `createHashMap(int expectedMapSize)` Utility method that creates an `HashMap` with its initialCapacity calculated to minimize rehash operations
    `static <K,V> Map<K,V>` | `createHashMapAdapter(int expectedMapSize)` Utility method that creates an `HashMapAdapter` with its initialCapacity calculated to minimize rehash operations
    `static <V> Int2ObjectHashMap<V>` | `createInt2ObjectHashMap(int expectedMapSize)` Utility method that creates an `Int2ObjectHashMap` with its initialCapacity calculated to minimize rehash operations
    `static <K,V> Map<K,V>` | `createLinkedHashMap(int expectedMapSize)` Utility method that creates an `LinkedHashMap` with its initialCapacity calculated to minimize rehash operations
    `static boolean` | `isNullOrEmpty(Map map)` Test the given map and return `true` if the map is null or empty.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### createHashMap

          public static <K,V> Map<K,V> createHashMap(int expectedMapSize)

      Utility method that creates an `HashMap` with its initialCapacity calculated to minimize rehash operations

    - #### createHashMapAdapter

          public static <K,V> Map<K,V> createHashMapAdapter(int expectedMapSize)

      Utility method that creates an `HashMapAdapter` with its initialCapacity calculated to minimize rehash operations

    - #### createLinkedHashMap

          public static <K,V> Map<K,V> createLinkedHashMap(int expectedMapSize)

      Utility method that creates an `LinkedHashMap` with its initialCapacity calculated to minimize rehash operations

    - #### createConcurrentHashMap

          public static <K,V> ConcurrentMap<K,V> createConcurrentHashMap(int expectedMapSize)

      Utility method that creates an `LinkedHashMap` with its initialCapacity calculated to minimize rehash operations

    - #### createInt2ObjectHashMap

          public static <V> Int2ObjectHashMap<V> createInt2ObjectHashMap(int expectedMapSize)

      Utility method that creates an `Int2ObjectHashMap` with its initialCapacity calculated to minimize rehash operations

    - #### calculateInitialCapacity

          public static int calculateInitialCapacity(int expectedMapSize)

      Returns the initial hash map capacity needed for the expected map size. To avoid resizing the map, the initial capacity should be different than the expected size, depending on the load factor.
      Parameters:
        `expectedMapSize` - the expected map size
      Returns:
        the necessary initial capacity
      See Also:
        `HashMap`

    - #### isNullOrEmpty

          public static boolean isNullOrEmpty(Map map)

      Test the given map and return `true` if the map is null or empty.
      Parameters:
        `map` - the map to test
      Returns:
        `true` if `map` is null or empty, otherwise `false`.

Copyright © 2019. All rights reserved.