prune
prune copied to clipboard
Increase performance
Hello,
Would like to utilize all CPU's to build a rather large tree by using parallelStream like this but got strange results, some children is lost. Any suggestions?
Thanks
private static <S> boolean runPassAndReportIfProgress(Collection<Node<S>> nodes, BiPredicate<Node<S>,Node<S>> parentChildMatcher) { return nodes.parallelStream().filter(node -> !node.getParent().isPresent()).anyMatch(node -> nodes.stream().filter(p -> p != node).filter(p -> parentChildMatcher.test(p, node)) .findFirst().map(p -> {p.addChildNode(node); return p;}).isPresent()); }