de.frag.umlplugin.classcloud
Class BidirectionalMultiMap<E1,E2>

java.lang.Object
  extended by de.frag.umlplugin.classcloud.BidirectionalMultiMap<E1,E2>

public class BidirectionalMultiMap<E1,E2>
extends java.lang.Object

Bidirectional map that provides access to pairs of values that each can be used as key or value.


Constructor Summary
BidirectionalMultiMap()
           
 
Method Summary
 void add(E1 e1, E2 e2)
          Adds an element pair.
 int backwardKeyCount()
          Gets number of different elements that act as second element in element pairs.
 java.util.Collection<E2> backwardKeys()
          Gets collection of all elements that are second element of element pairs.
 void clear()
          Clears this map.
 int forwardKeyCount()
          Gets number of different elements that act as first element in element pairs.
 java.util.Collection<E1> forwardKeys()
          Gets collection of all elements that are first element of element pairs.
 java.util.Set<E1> getBackward(E2 key)
          Gets other element of element pair for given second element.
 java.util.Set<E2> getForward(E1 key)
          Gets other element of element pair for given first element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BidirectionalMultiMap

public BidirectionalMultiMap()
Method Detail

add

public void add(@NotNull
                E1 e1,
                @NotNull
                E2 e2)
Adds an element pair.

Parameters:
e1 - first element of pair
e2 - second element of pair

getForward

@Nullable
public java.util.Set<E2> getForward(@NotNull
                                             E1 key)
Gets other element of element pair for given first element.

Parameters:
key - first element of pair that acts as key.
Returns:
second element or null, if no pair exists where given element is first element

getBackward

@Nullable
public java.util.Set<E1> getBackward(@NotNull
                                              E2 key)
Gets other element of element pair for given second element.

Parameters:
key - second element of pair that acts as key.
Returns:
first element or null, if no pair exists where given element is second element

forwardKeys

@NotNull
public java.util.Collection<E1> forwardKeys()
Gets collection of all elements that are first element of element pairs.

Returns:
collection of first elements in all pairs

backwardKeys

@NotNull
public java.util.Collection<E2> backwardKeys()
Gets collection of all elements that are second element of element pairs.

Returns:
collection of second elements in all pairs

forwardKeyCount

public int forwardKeyCount()
Gets number of different elements that act as first element in element pairs.

Returns:
number of different first elements

backwardKeyCount

public int backwardKeyCount()
Gets number of different elements that act as second element in element pairs.

Returns:
number of different second elements

clear

public void clear()
Clears this map.