org.opensha.commons.util
Class NtoNMap<Left,Right>

java.lang.Object
  extended by org.opensha.commons.util.NtoNMap<Left,Right>
Type Parameters:
Left -
Right -
Direct Known Subclasses:
SiteDataTypeParameterNameMap

public class NtoNMap<Left,Right>
extends Object

Class representing an N to N mapping. Similar to the java Map interface, but returns Collection's of values for each key instead of individual values.

Author:
Kevin Milner

Constructor Summary
NtoNMap()
           
 
Method Summary
 void clear()
           
 boolean containsMapping(Left left, Right right)
          Returns true if the specified mapping exists
 Set<Left> getLefts()
          Get all of the Lefts
 Collection<Left> getLefts(Right two)
          Get all of the Lefts for the given Right
 Set<Right> getRights()
          Get all of the Rights
 Collection<Right> getRights(Left one)
          Get all of the Rights for the given Left
 boolean isEmpty()
          Returns true if the size is 0
 void put(Left leftElem, Right rightElem)
          Add the mapping to the map
 void putAll(NtoNMap<Left,Right> map)
          Add all mappings from the given map
 boolean remove(Left left, Right right)
          Remove a mapping
 int size()
          Get the number of unique mappings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NtoNMap

public NtoNMap()
Method Detail

clear

public void clear()

put

public void put(Left leftElem,
                Right rightElem)
Add the mapping to the map

Parameters:
leftElem -
rightElem -

putAll

public void putAll(NtoNMap<Left,Right> map)
Add all mappings from the given map

Parameters:
map -

getLefts

public Set<Left> getLefts()
Get all of the Lefts

Returns:
Set

getLefts

public Collection<Left> getLefts(Right two)
Get all of the Lefts for the given Right

Parameters:
two -
Returns:

getRights

public Set<Right> getRights()
Get all of the Rights

Returns:

getRights

public Collection<Right> getRights(Left one)
Get all of the Rights for the given Left

Parameters:
one -
Returns:

containsMapping

public boolean containsMapping(Left left,
                               Right right)
Returns true if the specified mapping exists

Parameters:
left -
right -
Returns:

size

public int size()
Get the number of unique mappings

Returns:

isEmpty

public boolean isEmpty()
Returns true if the size is 0

Returns:

remove

public boolean remove(Left left,
                      Right right)
Remove a mapping

Parameters:
left -
right -
Returns:
success