org.eigenbase.util.mapping
Class Mappings.IdentityMapping

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

public static class Mappings.IdentityMapping
extends Mappings.AbstractMapping
implements Mappings.FunctionMapping, Mappings.TargetMapping, Mappings.SourceMapping


Field Summary
private  int size
           
 
Constructor Summary
Mappings.IdentityMapping(int size)
          Creates an identity mapping.
 
Method Summary
 MappingType getMappingType()
           
 int getSource(int target)
           
 int getSourceCount()
          Returns the number of sources.
 int getSourceOpt(int target)
           
 int getTarget(int source)
          Returns the target that a source maps to.
 int getTargetCount()
          Returns the number of targets.
 int getTargetOpt(int source)
          Returns the target that a source maps to, or -1 if it is not mapped.
 Mapping inverse()
           
 boolean isIdentity()
          Returns whether this mapping is the identity.
 Iterator<IntPair> iterator()
          Returns an iterator over the elements in this mapping.
 void set(int source, int target)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

private final int size
Constructor Detail

Mappings.IdentityMapping

public Mappings.IdentityMapping(int size)
Creates an identity mapping.

Parameters:
size - Size, or -1 if infinite.
Method Detail

inverse

public Mapping inverse()
Specified by:
inverse in interface Mappings.SourceMapping
Specified by:
inverse in interface Mappings.TargetMapping

isIdentity

public boolean isIdentity()
Description copied from interface: Mapping
Returns whether this mapping is the identity.

Specified by:
isIdentity in interface Mapping
Specified by:
isIdentity in interface Mappings.SourceMapping
Overrides:
isIdentity in class Mappings.AbstractMapping

set

public void set(int source,
                int target)
Specified by:
set in interface Mappings.TargetMapping
Overrides:
set in class Mappings.AbstractMapping

getMappingType

public MappingType getMappingType()
Specified by:
getMappingType in interface Mapping
Specified by:
getMappingType in interface Mappings.FunctionMapping
Specified by:
getMappingType in interface Mappings.SourceMapping
Specified by:
getMappingType in interface Mappings.TargetMapping

getSourceCount

public int getSourceCount()
Description copied from interface: Mapping
Returns the number of sources. Valid sources will be in the range 0 .. sourceCount.

Specified by:
getSourceCount in interface Mapping
Specified by:
getSourceCount in interface Mappings.FunctionMapping
Specified by:
getSourceCount in interface Mappings.SourceMapping
Specified by:
getSourceCount in interface Mappings.TargetMapping
Overrides:
getSourceCount in class Mappings.AbstractMapping

getTargetCount

public int getTargetCount()
Description copied from interface: Mapping
Returns the number of targets. Valid targets will be in the range 0 .. targetCount.

Specified by:
getTargetCount in interface Mapping
Specified by:
getTargetCount in interface Mappings.SourceMapping
Specified by:
getTargetCount in interface Mappings.TargetMapping
Overrides:
getTargetCount in class Mappings.AbstractMapping

getTarget

public int getTarget(int source)
Description copied from interface: Mappings.FunctionMapping
Returns the target that a source maps to.

Specified by:
getTarget in interface Mappings.FunctionMapping
Specified by:
getTarget in interface Mappings.TargetMapping
Overrides:
getTarget in class Mappings.AbstractMapping
Parameters:
source - source
Returns:
target

getTargetOpt

public int getTargetOpt(int source)
Description copied from interface: Mappings.FunctionMapping
Returns the target that a source maps to, or -1 if it is not mapped.

Specified by:
getTargetOpt in interface Mappings.FunctionMapping
Specified by:
getTargetOpt in interface Mappings.SourceMapping
Specified by:
getTargetOpt in interface Mappings.TargetMapping
Overrides:
getTargetOpt in class Mappings.AbstractMapping

getSource

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

getSourceOpt

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

iterator

public Iterator<IntPair> iterator()
Description copied from interface: Mapping
Returns an iterator over the elements in this mapping.

This method is optional; implementations may throw UnsupportedOperationException.

Specified by:
iterator in interface Iterable<IntPair>
Specified by:
iterator in interface Mapping