PermanentCommitsInfo<CommitId> () { return new PermanentCommitsInfo<>() { @Override public @NotNull CommitId getCommitId(int nodeId) { return myFunction.apply(nodeId); } @Override public long getTimestamp(int nodeId) { return myTimestampGetter.getTimestamp(nodeId); } @Override public int getNodeId(@NotNull CommitId commitId) { for (int id = 0; id < myLinearGraph.nodesCount(); id++) { if (myFunction.apply(id).equals(commitId)) { return id; } } return -1; } @Override public @NotNull Set<Integer> convertToNodeIds(@NotNull Collection<? extends CommitId> heads) { Set<Integer> result = new HashSet<>(); for (int id = 0; id < myLinearGraph.nodesCount(); id++) { if (heads.contains(myFunction.apply(id))) { result.add(id); } } return result; } }; }