private static MatchTableImpl createEmptyTable( VariantGraphRanking ranking, VariantGraph graph, Iterable<Token> witness) { // -2 === ignore the start and the end vertex return new MatchTableImpl( StreamSupport.stream(witness.spliterator(), false).toArray(Token[]::new), IntStream.range(0, Math.max(0, ranking.apply(graph.getEnd()) - 1)).toArray()); }
// move parameters into fields? private void fillTableWithMatches( VariantGraphRanking ranking, VariantGraph graph, Iterable<Token> witness, Comparator<Token> comparator) { Matches matches = Matches.between(graph.vertices(), witness, comparator); Set<Token> unique = matches.uniqueInWitness; Set<Token> ambiguous = matches.ambiguousInWitness; int rowIndex = 0; for (Token t : witness) { if (unique.contains(t) || ambiguous.contains(t)) { List<VariantGraph.Vertex> matchingVertices = matches.allMatches.getOrDefault(t, Collections.<VariantGraph.Vertex>emptyList()); for (VariantGraph.Vertex vgv : matchingVertices) { set(rowIndex, ranking.apply(vgv) - 1, t, vgv); } } rowIndex++; } }