edu.cs.ai.kreator.misc.util
Class Bijection<P,I>

java.lang.Object
  extended by edu.cs.ai.kreator.misc.util.Bijection<P,I>
Type Parameters:
P - the type of the pre-images
I - the type of the images
Direct Known Subclasses:
DataFileBijection

public class Bijection<P,I>
extends java.lang.Object

Author:
Markus Strauch

Field Summary
protected  java.util.Map<I,P> inverse
           
protected  java.util.Map<P,I> map
           
 
Constructor Summary
Bijection()
          Constructor.
 
Method Summary
 void add(P preImage, I image)
          Adds a pair of a pre-image and an image to the bijection.
 boolean containsImage(I image)
          Returns true if the bijection contains a mapping for the specified image.
 boolean containsPreImage(P preimage)
          Returns true if the bijection contains a mapping for the specified pre-image.
 java.util.Set<P> getAllPreImages()
          Returns all Pre-Images of the bijection
 I getImage(P preImage)
          Returns the image of the given pre-image
 java.util.Map<I,P> getInverseMap()
           
 java.util.Map<P,I> getMap()
           
 P getPreImage(I image)
          Returns the pre-image of the given image
 P removeImage(I image)
           
 I removePreImage(P preimage)
           
 java.util.Collection<I> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected java.util.Map<P,I> map

inverse

protected java.util.Map<I,P> inverse
Constructor Detail

Bijection

public Bijection()
Constructor.

Method Detail

add

public void add(P preImage,
                I image)
Adds a pair of a pre-image and an image to the bijection.

Parameters:
preImage - the pre-image
image - the image

removePreImage

public I removePreImage(P preimage)

removeImage

public P removeImage(I image)

getImage

public I getImage(P preImage)
Returns the image of the given pre-image

Parameters:
preImage -
Returns:

getPreImage

public P getPreImage(I image)
Returns the pre-image of the given image

Parameters:
image -
Returns:

getAllPreImages

public java.util.Set<P> getAllPreImages()
Returns all Pre-Images of the bijection

Returns:

values

public java.util.Collection<I> values()

containsPreImage

public boolean containsPreImage(P preimage)
Returns true if the bijection contains a mapping for the specified pre-image.

Parameters:
pre-image -
Returns:

containsImage

public boolean containsImage(I image)
Returns true if the bijection contains a mapping for the specified image.

Parameters:
image -
Returns:

getMap

public java.util.Map<P,I> getMap()

getInverseMap

public java.util.Map<I,P> getInverseMap()