コード例 #1
0
 /** Converts a {@link Map} of integers to a {@link TargetMapping}. */
 public static TargetMapping target(Map<Integer, Integer> map, int sourceCount, int targetCount) {
   final PartialFunctionImpl mapping =
       new PartialFunctionImpl(sourceCount, targetCount, MappingType.FUNCTION);
   for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
     mapping.set(entry.getKey(), entry.getValue());
   }
   return mapping;
 }
コード例 #2
0
 public static Mapping target(List<Integer> sources, int sourceCount) {
   final int targetCount = sources.size();
   final PartialFunctionImpl mapping =
       new PartialFunctionImpl(sourceCount, targetCount, MappingType.FUNCTION);
   for (int target = 0; target < targetCount; target++) {
     int source = sources.get(target);
     mapping.set(source, target);
   }
   return mapping;
 }
コード例 #3
0
 public static Mapping source(List<Integer> targets, int targetCount) {
   final int sourceCount = targets.size();
   final PartialFunctionImpl mapping =
       new PartialFunctionImpl(sourceCount, targetCount, MappingType.FUNCTION);
   for (int source = 0; source < sourceCount; source++) {
     int target = targets.get(source);
     mapping.set(source, target);
   }
   return mapping;
 }
コード例 #4
0
 public static TargetMapping target(
     Function1<Integer, Integer> function, int sourceCount, int targetCount) {
   final PartialFunctionImpl mapping =
       new PartialFunctionImpl(sourceCount, targetCount, MappingType.FUNCTION);
   for (int source = 0; source < sourceCount; source++) {
     Integer target = function.apply(source);
     if (target != null) {
       mapping.set(source, target);
     }
   }
   return mapping;
 }