Use JVM signatures instead of FQ-names for additional built-ins
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.utils;
|
||||
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
@@ -36,6 +37,30 @@ public class DFS {
|
||||
return dfs(nodes, neighbors, new VisitedWithSet<N>(), handler);
|
||||
}
|
||||
|
||||
public static <N> Boolean ifAny(
|
||||
@NotNull Collection<N> nodes,
|
||||
@NotNull Neighbors<N> neighbors,
|
||||
@NotNull final Function1<N, Boolean> predicate
|
||||
) {
|
||||
final boolean[] result = new boolean[1];
|
||||
|
||||
return dfs(nodes, neighbors, new AbstractNodeHandler<N, Boolean>() {
|
||||
@Override
|
||||
public boolean beforeChildren(N current) {
|
||||
if (predicate.invoke(current)) {
|
||||
result[0] = true;
|
||||
}
|
||||
|
||||
return !result[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean result() {
|
||||
return result[0];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static <N, R> R dfsFromNode(@NotNull N node, @NotNull Neighbors<N> neighbors, @NotNull Visited<N> visited, @NotNull NodeHandler<N, R> handler) {
|
||||
doDfs(node, neighbors, visited, handler);
|
||||
return handler.result();
|
||||
|
||||
Reference in New Issue
Block a user