org.eigenbase.util.mapping
Class Mappings.SurjectionWithInverse

java.lang.Object
  extended by org.eigenbase.util.mapping.Mappings.AbstractMapping
      extended by org.eigenbase.util.mapping.Mappings.FiniteAbstractMapping
          extended by org.eigenbase.util.mapping.Mappings.PartialMapping
              extended by org.eigenbase.util.mapping.Mappings.SurjectionWithInverse
All Implemented Interfaces:
Iterable<IntPair>, Mapping, Mappings.FunctionMapping, Mappings.SourceMapping, Mappings.TargetMapping
Enclosing class:
Mappings

static class Mappings.SurjectionWithInverse
extends Mappings.PartialMapping

A surjection with inverse has precisely one source for each target. (Whereas a general surjection has at least one source for each target.) Every source has at most one target.

If you call set(int, int) on a target, the target's previous source will be lost.


Field Summary
 
Fields inherited from class org.eigenbase.util.mapping.Mappings.PartialMapping
sources, targets
 
Constructor Summary
Mappings.SurjectionWithInverse(int sourceCount, int targetCount)
           
 
Method Summary
 int getSource(int target)
           
 void set(int source, int target)
          Creates a mapping between a source and a target.
 
Methods inherited from class org.eigenbase.util.mapping.Mappings.PartialMapping
getMappingType, getSourceCount, getSourceOpt, getTarget, getTargetCount, getTargetOpt, inverse, isIdentity, isValid, iterator
 
Methods inherited from class org.eigenbase.util.mapping.Mappings.FiniteAbstractMapping
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mappings.SurjectionWithInverse

Mappings.SurjectionWithInverse(int sourceCount,
                               int targetCount)
Method Detail

set

public void set(int source,
                int target)
Creates a mapping between a source and a target.

It is an error to map a target to a source which already has a target.

If you map a source to a target which already has a source, the old source becomes an orphan.

Specified by:
set in interface Mappings.TargetMapping
Overrides:
set in class Mappings.PartialMapping
Parameters:
source - source
target - target

getSource

public int getSource(int target)
Specified by:
getSource in interface Mappings.SourceMapping
Overrides:
getSource in class Mappings.AbstractMapping