public static class Mappings.PartialMapping extends Mappings.FiniteAbstractMapping implements Mapping, Mappings.FunctionMapping, Mappings.TargetMapping
| Modifier and Type | Field and Description |
|---|---|
protected int[] |
sources |
protected int[] |
targets |
| Constructor and Description |
|---|
Mappings.PartialMapping(int sourceCount,
int targetCount,
MappingType mappingType)
Creates a partial mapping.
|
Mappings.PartialMapping(List<Integer> sourceList,
int sourceCount,
MappingType mappingType)
Creates a partial mapping from a list.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all elements in the mapping.
|
MappingType |
getMappingType()
Returns the mapping type.
|
int |
getSourceCount()
Returns the number of sources.
|
int |
getSourceOpt(int target) |
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.
|
protected boolean |
isValid() |
Iterator<IntPair> |
iterator()
Returns an iterator over the elements in this mapping.
|
void |
set(int source,
int target) |
int |
size()
Returns the number of elements in the mapping.
|
equals, hashCodegetSource, getTarget, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetSourcegetTargetpublic Mappings.PartialMapping(int sourceCount,
int targetCount,
MappingType mappingType)
Initially, no element is mapped to any other:
| source | 0 | 1 | 2 |
|---|---|---|---|
| target | -1 | -1 | -1 |
| target | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| source | -1 | -1 | -1 | -1 |
sourceCount - Number of source elementstargetCount - Number of target elementsmappingType - Mapping type; must not allow multiple sources per
target or multiple targets per sourcepublic Mappings.PartialMapping(List<Integer> sourceList, int sourceCount, MappingType mappingType)
PartialMapping({1, 2, 4}, 6) creates the mapping
| source | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| target | -1 | 0 | 1 | -1 | 2 | -1 |
sourceList - List whose i'th element is the source of target #isourceCount - Number of elements in the source domainmappingType - Mapping type, must be
MappingType.PARTIAL_SURJECTION
or stronger.public MappingType getMappingType()
Mappings.CoreMappinggetMappingType in interface MappinggetMappingType in interface Mappings.CoreMappinggetMappingType in interface Mappings.FunctionMappinggetMappingType in interface Mappings.SourceMappingpublic int getSourceCount()
MappinggetSourceCount in interface MappinggetSourceCount in interface Mappings.FunctionMappinggetSourceCount in interface Mappings.SourceMappinggetSourceCount in interface Mappings.TargetMappinggetSourceCount in class Mappings.AbstractMappingpublic int getTargetCount()
MappinggetTargetCount in interface MappinggetTargetCount in interface Mappings.SourceMappinggetTargetCount in interface Mappings.TargetMappinggetTargetCount in class Mappings.AbstractMappingpublic void clear()
Mappingpublic int size()
Mappingsize in interface Mappingsize in interface Mappings.CoreMappingpublic Mapping inverse()
inverse in interface Mappings.SourceMappinginverse in interface Mappings.TargetMappingpublic Iterator<IntPair> iterator()
MappingThis method is optional; implementations may throw
UnsupportedOperationException.
protected boolean isValid()
public void set(int source,
int target)
set in interface Mappings.TargetMappingset in class Mappings.AbstractMappingpublic int getSourceOpt(int target)
getSourceOpt in interface Mappings.SourceMappinggetSourceOpt in interface Mappings.TargetMappinggetSourceOpt in class Mappings.AbstractMappingpublic int getTargetOpt(int source)
Mappings.FunctionMappinggetTargetOpt in interface Mappings.FunctionMappinggetTargetOpt in interface Mappings.SourceMappinggetTargetOpt in interface Mappings.TargetMappinggetTargetOpt in class Mappings.AbstractMappingpublic boolean isIdentity()
MappingisIdentity in interface MappingisIdentity in interface Mappings.SourceMappingisIdentity in class Mappings.AbstractMappingCopyright © 2012–2015 The Apache Software Foundation. All rights reserved.