StepRef stepRef(TableRef source, TableRef target, List<IntPair> keys) {
keys = LatticeSpace.sortUnique(keys);
final Step h = new Step(source.table, target.table, keys);
if (h.isBackwards(space.statisticProvider)) {
final List<IntPair> keys1 = LatticeSpace.swap(h.keys);
final Step h2 = space.addEdge(h.target(), h.source(), keys1);
return new StepRef(target, source, h2, stepRefCount++);
} else {
final Step h2 = space.addEdge(h.source(), h.target(), h.keys);
return new StepRef(source, target, h2, stepRefCount++);
}
}
}