TUM CCSM Commons

edu.tum.cs.commons.collections
Class BidirectionalMap<S,T>

java.lang.Object
  extended by edu.tum.cs.commons.collections.BidirectionalMap<S,T>

public class BidirectionalMap<S,T>
extends java.lang.Object

A collection which implements a bidirectional mapping.

Version:
$Rev: 26283 $
Author:
hummelb, $Author: juergens $
Rating:
GREEN Hash: F1003ED1FCC22EA4403DCC0EAC9625F2

Constructor Summary
BidirectionalMap()
          Creates new bidirectional map based on hash maps.
BidirectionalMap(java.util.Map<S,T> stMap, java.util.Map<T,S> tsMap)
          Creates new bidirectional map based given maps.
 
Method Summary
 void clear()
          Clears the map.
 boolean containsFirst(S s)
          Returns whether the given element is in the first set (the domain of the bijection).
 boolean containsSecond(T t)
          Returns whether the given element is in the second set (the range of the bijection).
 UnmodifiableSet<java.util.Map.Entry<S,T>> getEntrySet()
          Returns the entries.
 S getFirst(T t)
          Get first element.
 UnmodifiableSet<S> getFirstSet()
          Returns the first set (the domain).
 UnmodifiableSet<java.util.Map.Entry<T,S>> getInvertedEntrySet()
          Returns the inverted entries.
 T getSecond(S s)
          Get second element.
 UnmodifiableSet<T> getSecondSet()
          Returns the second set (the range).
 boolean isEmpty()
          Returns whether this map is empty.
 void put(S s, T t)
          Inserts the given pair into the bijection.
 void removeFirst(S s)
          Removes the first object
 void removeSecond(T t)
          Removes the second object
 int size()
          Returns the size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BidirectionalMap

public BidirectionalMap()
Creates new bidirectional map based on hash maps.


BidirectionalMap

public BidirectionalMap(java.util.Map<S,T> stMap,
                        java.util.Map<T,S> tsMap)
Creates new bidirectional map based given maps.

Method Detail

getFirst

public S getFirst(T t)
Get first element.


getSecond

public T getSecond(S s)
Get second element.


isEmpty

public boolean isEmpty()
Returns whether this map is empty.


size

public int size()
Returns the size.


clear

public void clear()
Clears the map.


containsFirst

public boolean containsFirst(S s)
Returns whether the given element is in the first set (the domain of the bijection).


containsSecond

public boolean containsSecond(T t)
Returns whether the given element is in the second set (the range of the bijection).


getFirstSet

public UnmodifiableSet<S> getFirstSet()
Returns the first set (the domain).


getSecondSet

public UnmodifiableSet<T> getSecondSet()
Returns the second set (the range).


getEntrySet

public UnmodifiableSet<java.util.Map.Entry<S,T>> getEntrySet()
Returns the entries.


getInvertedEntrySet

public UnmodifiableSet<java.util.Map.Entry<T,S>> getInvertedEntrySet()
Returns the inverted entries.


put

public void put(S s,
                T t)
Inserts the given pair into the bijection. Any mapping associated with those values is removed before. This map does not support null values.


removeFirst

public void removeFirst(S s)
Removes the first object


removeSecond

public void removeSecond(T t)
Removes the second object


TUM CCSM Commons

TUM CCSM Commons - 2.7