public static class Mappings.PartialMapping extends Mappings.FiniteAbstractMapping implements Mapping, Mappings.FunctionMapping, Mappings.TargetMapping
Modifier and Type | Class and Description |
---|---|
private class |
Mappings.PartialMapping.MappingItr
Mapping iterator.
|
Modifier and Type | Field and Description |
---|---|
private MappingType |
mappingType |
protected int[] |
sources |
protected int[] |
targets |
Modifier | Constructor and Description |
---|---|
private |
PartialMapping(int[] sources,
int[] targets,
MappingType mappingType) |
|
PartialMapping(int sourceCount,
int targetCount,
MappingType mappingType)
Creates a partial mapping.
|
|
PartialMapping(java.util.List<java.lang.Integer> sourceList,
int sourceCount,
MappingType mappingType)
Creates a partial mapping from a list.
|
Modifier and Type | Method and Description |
---|---|
private static void |
assertPartialValid(int[] sources,
int[] targets) |
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() |
java.util.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, hashCode
getSource, getTarget, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getSource
getTarget
protected final int[] sources
protected final int[] targets
private final MappingType mappingType
public 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 PartialMapping(java.util.List<java.lang.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.private PartialMapping(int[] sources, int[] targets, MappingType mappingType)
public MappingType getMappingType()
Mappings.CoreMapping
getMappingType
in interface Mapping
getMappingType
in interface Mappings.CoreMapping
getMappingType
in interface Mappings.FunctionMapping
getMappingType
in interface Mappings.SourceMapping
public int getSourceCount()
Mapping
getSourceCount
in interface Mapping
getSourceCount
in interface Mappings.FunctionMapping
getSourceCount
in interface Mappings.SourceMapping
getSourceCount
in interface Mappings.TargetMapping
getSourceCount
in class Mappings.AbstractMapping
public int getTargetCount()
Mapping
getTargetCount
in interface Mapping
getTargetCount
in interface Mappings.SourceMapping
getTargetCount
in interface Mappings.TargetMapping
getTargetCount
in class Mappings.AbstractMapping
public void clear()
Mapping
public int size()
Mapping
size
in interface Mapping
size
in interface Mappings.CoreMapping
public Mapping inverse()
inverse
in interface Mappings.SourceMapping
inverse
in interface Mappings.TargetMapping
public java.util.Iterator<IntPair> iterator()
Mapping
This method is optional; implementations may throw
UnsupportedOperationException
.
iterator
in interface java.lang.Iterable<IntPair>
iterator
in interface Mapping
iterator
in class Mappings.FiniteAbstractMapping
protected boolean isValid()
private static void assertPartialValid(int[] sources, int[] targets)
public void set(int source, int target)
set
in interface Mappings.TargetMapping
set
in class Mappings.AbstractMapping
public int getSourceOpt(int target)
getSourceOpt
in interface Mappings.SourceMapping
getSourceOpt
in interface Mappings.TargetMapping
getSourceOpt
in class Mappings.AbstractMapping
public int getTargetOpt(int source)
Mappings.FunctionMapping
getTargetOpt
in interface Mappings.FunctionMapping
getTargetOpt
in interface Mappings.SourceMapping
getTargetOpt
in interface Mappings.TargetMapping
getTargetOpt
in class Mappings.AbstractMapping
public boolean isIdentity()
Mapping
isIdentity
in interface Mapping
isIdentity
in interface Mappings.SourceMapping
isIdentity
in class Mappings.AbstractMapping
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.