
impl.treelinearizers.FullTreeLinearizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flexible-tree Show documentation
Show all versions of flexible-tree Show documentation
Library for generating permutation of given value domains
The newest version!
package impl.treelinearizers;
import api.ChildTree;
import api.Node;
import api.utils.NodePath;
import api.utils.TreeLinearizer;
import impl.nodepaths.ImmutableNodePath;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* Builds a collection of immutable NodePaths. It contains all the node paths the tree including
* nodes that are not leafs
*/
public class FullTreeLinearizer implements TreeLinearizer {
@Override
public Predicate>, ChildTree>> getFilter() {
return nodePathChildTreeEntry -> {
boolean empty = nodePathChildTreeEntry.getValue().getNodes().isEmpty();
return empty;
};
}
@Override
public NodeConverter getConverter() {
return nodePath -> {
NodePath> path = nodePath.getKey();
List nodes = path.getNodes().parallelStream().map(node -> node.getValue().getValue()).collect(Collectors.toList());
return new ImmutableNodePath<>(nodes);
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy