org.eigenbase.util.mapping
Enum MappingType

java.lang.Object
  extended by java.lang.Enum<MappingType>
      extended by org.eigenbase.util.mapping.MappingType
All Implemented Interfaces:
Serializable, Comparable<MappingType>

public enum MappingType
extends Enum<MappingType>

Describes the type of a mapping, from the most general MultiFunction (every element in the source and target domain can participate in many mappings) to the most retricted Bijection (every element in the source and target domain must be paired with precisely one element in the other domain).

Some common types:

Once you know what type of mapping you want, call Mappings.create(MappingType, int, int) to create an efficient implementation of that mapping.

Since:
Mar 24, 2006
Version:
$Id: //open/dev/farrago/src/org/eigenbase/util/mapping/MappingType.java#10 $
Author:
jhyde

Enum Constant Summary
Bijection
           
Eleven
           
Fourteen
           
Function
           
Injection
           
InverseFunction
          An inverse function has a source for every target, but a source might have 0, 1 or more targets.
InverseInjection
           
InversePartialFunction
           
InversePartialInjection
           
InverseSurjection
          An inverse surjection has a source for every target, and no source has more than one target.
MultiFunction
           
PartialFunction
           
PartialInjection
           
PartialSurjection
          A partial surjection has no more than one source for any target, and no more than one target for any source.
Surjection
           
Ten
           
 
Field Summary
private  int inverseOrdinal
           
private static int MultipleSource
          Allow more than one source for a given target.
private static int MultipleTarget
          Allow more than one target for a given source.
private static int OptionalSource
          Allow less than one source for a given target.
private static int OptionalTarget
          Allow less than one target for a given source.
 
Method Summary
 MappingType inverse()
           
 boolean isA(MappingType mappingType)
          Returns whether this mapping type is (possibly a weaker form of) a given mapping type.
 boolean isBijection()
          A mapping is a bijection if it is a surjection and it is an injection.
 boolean isFunction()
          A mapping is a total function if every source has precisely one target.
 boolean isInjection()
          A mapping is an injection if it is a function and no target has more than one source.
 boolean isMandatorySource()
          Constraint that every target has at least one source.
 boolean isMandatoryTarget()
          Constraint that every source has at least one target.
 boolean isPartialFunction()
          A mapping is a partial function if every source has at most one target.
 boolean isSingleSource()
          Constraint that every target has at most one source.
 boolean isSingleTarget()
          Constraint that every source has at most one target.
 boolean isSurjection()
          A mapping is a surjection if it is a function and every target has at least one source.
static MappingType valueOf(String name)
          Returns the enum constant of this type with the specified name.
static MappingType[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

Bijection

public static final MappingType Bijection

Surjection

public static final MappingType Surjection

Injection

public static final MappingType Injection

Function

public static final MappingType Function

InverseSurjection

public static final MappingType InverseSurjection
An inverse surjection has a source for every target, and no source has more than one target.


PartialSurjection

public static final MappingType PartialSurjection
A partial surjection has no more than one source for any target, and no more than one target for any source.


PartialInjection

public static final MappingType PartialInjection

PartialFunction

public static final MappingType PartialFunction

InverseInjection

public static final MappingType InverseInjection

InversePartialInjection

public static final MappingType InversePartialInjection

Ten

public static final MappingType Ten

Eleven

public static final MappingType Eleven

InverseFunction

public static final MappingType InverseFunction
An inverse function has a source for every target, but a source might have 0, 1 or more targets.

Obeys the constaints isMandatorySource(), isSingleSource().

Similar types:


InversePartialFunction

public static final MappingType InversePartialFunction

Fourteen

public static final MappingType Fourteen

MultiFunction

public static final MappingType MultiFunction
Field Detail

inverseOrdinal

private final int inverseOrdinal

OptionalSource

private static final int OptionalSource
Allow less than one source for a given target.

See Also:
Constant Field Values

MultipleSource

private static final int MultipleSource
Allow more than one source for a given target.

See Also:
Constant Field Values

OptionalTarget

private static final int OptionalTarget
Allow less than one target for a given source.

See Also:
Constant Field Values

MultipleTarget

private static final int MultipleTarget
Allow more than one target for a given source.

See Also:
Constant Field Values
Method Detail

values

public static final MappingType[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(MappingType c : MappingType.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static MappingType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name

inverse

public MappingType inverse()

isA

public boolean isA(MappingType mappingType)
Returns whether this mapping type is (possibly a weaker form of) a given mapping type.

For example, a Bijection is a Function, but not every {link #Function} is a Bijection.


isFunction

public boolean isFunction()
A mapping is a total function if every source has precisely one target.


isPartialFunction

public boolean isPartialFunction()
A mapping is a partial function if every source has at most one target.


isSurjection

public boolean isSurjection()
A mapping is a surjection if it is a function and every target has at least one source.


isInjection

public boolean isInjection()
A mapping is an injection if it is a function and no target has more than one source. (In other words, every source has precisely one target.)


isBijection

public boolean isBijection()
A mapping is a bijection if it is a surjection and it is an injection. (In other words,


isMandatoryTarget

public boolean isMandatoryTarget()
Constraint that every source has at least one target.


isSingleTarget

public boolean isSingleTarget()
Constraint that every source has at most one target.


isMandatorySource

public boolean isMandatorySource()
Constraint that every target has at least one source.


isSingleSource

public boolean isSingleSource()
Constraint that every target has at most one source.