diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-10 16:40:33 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-10 16:40:33 -0400 |
| commit | 889fac2bdf993dc86f64a8893c0260fdcf848acb (patch) | |
| tree | 99ed08552efa86fdc5fdf4ddb8720d10e599fafe /BJC-Utils2/src/main/java/bjc/utils/data/ITree.java | |
| parent | 1656b02144446aeedebb3d1179e07ed99c01861c (diff) | |
Cleanup
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/ITree.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/ITree.java | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/ITree.java b/BJC-Utils2/src/main/java/bjc/utils/data/ITree.java index 166fe3f..ff374e8 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/ITree.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/ITree.java @@ -1,18 +1,18 @@ package bjc.utils.data; -import bjc.utils.funcdata.bst.TreeLinearizationMethod; -import bjc.utils.functypes.ListFlattener; - import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.UnaryOperator; +import bjc.utils.funcdata.bst.TreeLinearizationMethod; +import bjc.utils.functypes.ListFlattener; + /** * A node in a homogeneous tree with a unlimited amount of children. * * @author ben - * + * * @param <ContainedType> * The type of data contained in the tree nodes. * @@ -28,7 +28,7 @@ public interface ITree<ContainedType> { /** * Prepend a child to this node. - * + * * @param child * The child to prepend to this node. */ @@ -39,21 +39,21 @@ public interface ITree<ContainedType> { * * @param <NewType> * The intermediate type being folded. - * + * * @param <ReturnedType> * The type that is the end result. - * + * * @param leafTransform * The function to use to convert leaf values. - * + * * @param nodeCollapser * The function to use to convert internal nodes and * their children. - * + * * @param resultTransformer * The function to use to convert a state to the returned * version. - * + * * @return The final transformed state. */ <NewType, ReturnedType> ReturnedType collapse(Function<ContainedType, NewType> leafTransform, @@ -74,13 +74,13 @@ public interface ITree<ContainedType> { * * @param mapper * The function to use to map values into trees. - * + * * @return A tree, with some nodes expanded into trees. */ - default ITree<ContainedType> flatMapTree(Function<ContainedType, ITree<ContainedType>> mapper) { + default ITree<ContainedType> flatMapTree(final Function<ContainedType, ITree<ContainedType>> mapper) { return topDownTransform(dat -> TopDownTransformResult.PUSHDOWN, node -> { if (node.getChildrenCount() > 0) { - ITree<ContainedType> parent = node.transformHead(mapper); + final ITree<ContainedType> parent = node.transformHead(mapper); node.doForChildren(parent::addChild); @@ -96,10 +96,10 @@ public interface ITree<ContainedType> { * * @param childNo * The number of the child to get. - * + * * @return The specified child of this tree. */ - default ITree<ContainedType> getChild(int childNo) { + default ITree<ContainedType> getChild(final int childNo) { return transformChild(childNo, child -> child); } @@ -124,13 +124,13 @@ public interface ITree<ContainedType> { * * @param <MappedType> * The type of the new tree. - * + * * @param leafTransformer * The function to use to transform leaf tokens. - * + * * @param operatorTransformer * The function to use to transform internal tokens. - * + * * @return The tree, with the nodes changed. */ <MappedType> ITree<MappedType> rebuildTree(Function<ContainedType, MappedType> leafTransformer, @@ -141,7 +141,7 @@ public interface ITree<ContainedType> { * * @param nodePicker * The predicate to use to pick nodes to transform. - * + * * @param transformer * The function to use to transform picked nodes. */ @@ -152,10 +152,10 @@ public interface ITree<ContainedType> { * * @param transformPicker * The function to use to pick how to progress. - * + * * @param transformer * The function used to transform picked subtrees. - * + * * @return The tree with the transform applied to picked subtrees. */ ITree<ContainedType> topDownTransform(Function<ContainedType, TopDownTransformResult> transformPicker, @@ -166,13 +166,13 @@ public interface ITree<ContainedType> { * * @param <TransformedType> * The type of the transformed value. - * + * * @param childNo * The number of the child to transform. - * + * * @param transformer * The function to use to transform the value. - * + * * @return The transformed value. * * @throws IllegalArgumentException @@ -187,10 +187,10 @@ public interface ITree<ContainedType> { * * @param <TransformedType> * The type of the transformed value. - * + * * @param transformer * The function to use to transform the value. - * + * * @return The transformed value. */ <TransformedType> TransformedType transformHead(Function<ContainedType, TransformedType> transformer); @@ -200,13 +200,13 @@ public interface ITree<ContainedType> { * * @param <MappedType> * The type of the new tree. - * + * * @param transformer * The function to use to transform tokens. - * + * * @return A tree with the token types transformed. */ - default <MappedType> ITree<MappedType> transformTree(Function<ContainedType, MappedType> transformer) { + default <MappedType> ITree<MappedType> transformTree(final Function<ContainedType, MappedType> transformer) { return rebuildTree(transformer, transformer); } @@ -215,7 +215,7 @@ public interface ITree<ContainedType> { * * @param linearizationMethod * The way to traverse the tree. - * + * * @param action * The action to perform on each tree node. */ @@ -223,10 +223,10 @@ public interface ITree<ContainedType> { /** * Find the farthest to right child that satisfies the given predicate. - * + * * @param childPred * The predicate to satisfy. - * + * * @return The index of the right-most child that satisfies the * predicate, or -1 if one doesn't exist. */ |
