Class HashMultimap<A,B>

java.lang.Object
eu.bandm.tools.util.multi.MapMultimap<A,B>
eu.bandm.tools.util.multi.HashMultimap<A,B>
Type Parameters:
A - type of the domain elements
B - type of the range elements
All Implemented Interfaces:
Multimap<A,B>, Serializable, Iterable<Map.Entry<A,B>>, Collection<Map.Entry<A,B>>, BiPredicate<A,B>, Set<Map.Entry<A,B>>

public class HashMultimap<A,B> extends MapMultimap<A,B> implements Serializable
An Implementation where both directions of look-up are realized by hashing.
See Also:
  • Constructor Details

    • HashMultimap

      public HashMultimap()
      Constructs an empty multimap.
    • HashMultimap

      public HashMultimap(Collection<? extends Map.Entry<A,B>> c)
      Constructs a multimap which contains all pairs given in the argument. Both collections will be independent.

      (Subclasses must avoid this-escape: Multimap.addAll(java.util.Collection<? extends java.util.Map.Entry<A, B>>) is invoked.)

      Parameters:
      c - the pairs to include in the constructed multimap
    • HashMultimap

      public HashMultimap(Map<A,B> m)
      Constructs a multimap which contains all pairs given in the argument. Both collections will be independent.
      Parameters:
      m - the pairs to include in the constructed multimap
    • HashMultimap

      public HashMultimap(HashMultimap<A,B> r)
      Constructs a multimap which is a copy of the given multimap. Both multimaps will be independent.
      Parameters:
      r - the pairs to include in the constructed multimap
  • Method Details

    • createForwardSet

      protected Set<B> createForwardSet()
      Creates the image set for every domain element added.

      Subclasses implementing this method must ensure that when the map A->Set<B> is sorted, then this set also is.

      This class creates HashMaps.

      Specified by:
      createForwardSet in class MapMultimap<A,B>
      Returns:
      a sets for range domain elements assigned to one particular domain element.
    • createBackwardSet

      protected Set<A> createBackwardSet()
      Creates the preimage set for every range element added.

      Subclasses implementing this method must ensure that when the map B->Set<A> is sorted, then this set also is.

      This class creates HashMaps.

      Specified by:
      createBackwardSet in class MapMultimap<A,B>
      Returns:
      a sets for the domain elements assigned to one particular range element.