prune icon indicating copy to clipboard operation
prune copied to clipboard

Increase performance

Open Hugolarson opened this issue 4 years ago • 0 comments

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()); }

Hugolarson avatar Jan 23 '21 07:01 Hugolarson