Class Maps2

    • Constructor Summary

      Constructors 
      Constructor Description
      Maps2()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      java.util.LinkedHashMap<K,​V>
      newLinkedHashMapWithExpectedSize​(int expectedSize)
      Creates a LinkedHashMap instance, with a high enough "initial capacity" that it should hold expectedSize elements without growth.
      static <K,​V>
      void
      putAllIntoListMap​(K key, java.util.Collection<? extends V> values, java.util.Map<? super K,​java.util.List<V>> map)
      Puts a value into a map that supports lists as values.
      static <K,​V>
      void
      putIntoListMap​(K key, V value, java.util.Map<? super K,​java.util.List<V>> map)
      Puts a value into a map that supports lists as values.
      static <K,​V>
      void
      putIntoSetMap​(K key, V value, java.util.Map<? super K,​java.util.Set<V>> map)
      Puts a value into a map that supports lists as values.
      • Methods inherited from class java.lang.Object

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

      • Maps2

        public Maps2()
    • Method Detail

      • newLinkedHashMapWithExpectedSize

        public static <K,​V> java.util.LinkedHashMap<K,​V> newLinkedHashMapWithExpectedSize​(int expectedSize)
        Creates a LinkedHashMap instance, with a high enough "initial capacity" that it should hold expectedSize elements without growth. This behavior cannot be broadly guaranteed, but it is observed to be true for OpenJDK 1.6. It also can't be guaranteed that the method isn't inadvertently oversizing the returned map.
        Parameters:
        expectedSize - the number of elements you expect to add to the returned map
        Returns:
        a new, empty LinkedHashMap with enough capacity to hold expectedSize elements without resizing
        Throws:
        java.lang.IllegalArgumentException - if expectedSize is negative
      • putIntoListMap

        public static <K,​V> void putIntoListMap​(K key,
                                                      V value,
                                                      java.util.Map<? super K,​java.util.List<V>> map)
        Puts a value into a map that supports lists as values. The list is created on-demand.
      • putIntoSetMap

        public static <K,​V> void putIntoSetMap​(K key,
                                                     V value,
                                                     java.util.Map<? super K,​java.util.Set<V>> map)
        Puts a value into a map that supports lists as values. The list is created on-demand.
      • putAllIntoListMap

        public static <K,​V> void putAllIntoListMap​(K key,
                                                         java.util.Collection<? extends V> values,
                                                         java.util.Map<? super K,​java.util.List<V>> map)
        Puts a value into a map that supports lists as values. The list is created on-demand.