Class HashMultiMap<K,V>

java.lang.Object
com.github.tadukoo.util.map.MultiMap<K,V>
com.github.tadukoo.util.map.HashMultiMap<K,V>

public class HashMultiMap<K,V> extends MultiMap<K,V>
A MultiMap class that uses HashMap as the backing Map class.
Since:
Pre-Alpha
Version:
Alpha v.0.2
Author:
Logan Ferree (Tadukoo)
  • Constructor Details

    • HashMultiMap

      public HashMultiMap()
      Creates a new HashMultiMap where the backing HashMap is constructed with the default initial capacity (16) and the default load factor (0.75).
    • HashMultiMap

      public HashMultiMap(int initialCapacity)
      Creates a new HashMultiMap where the backing HashMap is constructed with the specified initial capacity and the default load factor (0.75).
      Parameters:
      initialCapacity - The initial capacity of the backing HashMap
    • HashMultiMap

      public HashMultiMap(int initialCapacity, float loadFactor)
      Creates a new HashMultiMap where the backing HashMap is constructed with the specified initial capacity and load factor.
      Parameters:
      initialCapacity - The initial capacity of the backing HashMap
      loadFactor - The load factor of the backing HashMap
    • HashMultiMap

      @SafeVarargs public HashMultiMap(Pair<K,V>... entries)
      Creates a new HashMultiMap where the given Pairs are loaded into the map right away.
      Parameters:
      entries - The Pairs to be placed in this MultiMap
    • HashMultiMap

      public HashMultiMap(Map<K,V> map)
      Creates a new HashMultiMap where the backing HashMap is constructed with the same mappings as the specified Map. The HashMap is created with default load factor (0.75) and an initial capacity sufficient to hold the mappings in the specified Map.
      Parameters:
      map - The Map whose mappings are to be placed in the backing HashMap
    • HashMultiMap

      public HashMultiMap(MultiMap<K,V> multiMap)
      Creates a new HashMultiMap where the backing HashMap is constructed with the default initial capacity (16) and the default load factor (0.75).
      The MultiMap is then populated with the values present in the specified MultiMap.
      Parameters:
      multiMap - The MultiMap whose mappings are to be placed in this MultiMap
  • Method Details

    • equals

      public boolean equals(Object o)
      Compares the given object with this HashMultiMap for equality. Returns true if the given object is also a HashMultiMap and the two HashMultiMaps represent the same mappings. If they're both HashMultiMaps, it will run MultiMap.equals(java.lang.Object) to compare them.
      Overrides:
      equals in class MultiMap<K,V>
      Parameters:
      o - The object to be compared for equality with this HashMultiMap
      Returns:
      true if the given object is equivalent to this HashMultiMap
    • asMap

      public HashMap<K,List<V>> asMap()
      Returns the underlying HashMap of this HashMultiMap.
      Overrides:
      asMap in class MultiMap<K,V>
      Returns:
      The underlying HashMap