private static class Mappings.PartialFunctionImpl extends Mappings.AbstractMapping implements Mappings.TargetMapping
Mapping where a source can have at most one
target, and a target can have any number of sources. The source count
must be finite, but the target count may be infinite.
The implementation uses an array for the forward-mapping, but does not store the backward mapping.
| Modifier and Type | Field and Description |
|---|---|
private MappingType |
mappingType |
private int |
sourceCount |
private int |
targetCount |
private int[] |
targets |
| Constructor and Description |
|---|
PartialFunctionImpl(int sourceCount,
int targetCount,
MappingType mappingType) |
| 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 |
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() |
Iterator<IntPair> |
iterator()
Returns an iterator over the elements in this mapping.
|
void |
set(int source,
int target) |
void |
setAll(Mapping mapping) |
int |
size()
Returns the number of elements in the mapping.
|
getSource, getSourceOpt, getTarget, isIdentity, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetSourceOpt, getTargetforEach, spliteratorprivate final int sourceCount
private final int targetCount
private final MappingType mappingType
private final int[] targets
PartialFunctionImpl(int sourceCount,
int targetCount,
MappingType mappingType)
public 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()
Mappings.CoreMappingsize in interface Mappingsize in interface Mappings.CoreMappingpublic Iterator<IntPair> iterator()
MappingThis method is optional; implementations may throw
UnsupportedOperationException.
public MappingType getMappingType()
Mappings.CoreMappinggetMappingType in interface MappinggetMappingType in interface Mappings.CoreMappinggetMappingType in interface Mappings.FunctionMappinggetMappingType in interface Mappings.SourceMappingpublic Mapping inverse()
inverse in interface Mappings.SourceMappinginverse in interface Mappings.TargetMappingpublic void set(int source,
int target)
set in interface Mappings.TargetMappingset in class Mappings.AbstractMappingpublic void setAll(Mapping mapping)
public int getTargetOpt(int source)
Mappings.FunctionMappinggetTargetOpt in interface Mappings.FunctionMappinggetTargetOpt in interface Mappings.SourceMappinggetTargetOpt in interface Mappings.TargetMappinggetTargetOpt in class Mappings.AbstractMappingCopyright © 2012–2018 The Apache Software Foundation. All rights reserved.