summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/funcdata
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java38
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java16
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java4
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java2
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeNode.java5
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/TreeLinearizationMethod.java8
6 files changed, 37 insertions, 36 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java
index 735c664..c8f2269 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java
@@ -1,5 +1,6 @@
package bjc.utils.funcdata;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@@ -16,8 +17,6 @@ import bjc.utils.data.IPair;
import bjc.utils.data.Identity;
import bjc.utils.data.Pair;
-import java.util.ArrayList;
-
/**
* A wrapper over another list that provides eager functional operations
* over it. Differs from a stream in every way except for the fact that
@@ -182,8 +181,8 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
// Get the iterator for the other list
Iterator<T> rightIterator = rightList.toIterable().iterator();
- for (Iterator<E> leftIterator =
- wrappedList.iterator(); leftIterator.hasNext()
+ for (Iterator<E> leftIterator = wrappedList
+ .iterator(); leftIterator.hasNext()
&& rightIterator.hasNext();) {
// Add the transformed items to the result list
E leftVal = leftIterator.next();
@@ -228,18 +227,18 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
* Function)
*/
@Override
- public <T> IFunctionalList<T>
- flatMap(Function<E, IFunctionalList<T>> elementExpander) {
+ public <T> IFunctionalList<T> flatMap(
+ Function<E, IFunctionalList<T>> elementExpander) {
if (elementExpander == null) {
throw new NullPointerException("Expander must not be null");
}
- IFunctionalList<T> returnedList =
- new FunctionalList<>(this.wrappedList.size());
+ IFunctionalList<T> returnedList = new FunctionalList<>(
+ this.wrappedList.size());
forEach(element -> {
- IFunctionalList<T> expandedElement =
- elementExpander.apply(element);
+ IFunctionalList<T> expandedElement = elementExpander
+ .apply(element);
if (expandedElement == null) {
throw new NullPointerException(
@@ -370,8 +369,8 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
throw new NullPointerException("Transformer must be not null");
}
- IFunctionalList<T> returnedList =
- new FunctionalList<>(this.wrappedList.size());
+ IFunctionalList<T> returnedList = new FunctionalList<>(
+ this.wrappedList.size());
forEach(element -> {
// Add the transformed item to the result
@@ -388,8 +387,8 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
* IFunctionalList)
*/
@Override
- public <T> IFunctionalList<IPair<E, T>>
- pairWith(IFunctionalList<T> rightList) {
+ public <T> IFunctionalList<IPair<E, T>> pairWith(
+ IFunctionalList<T> rightList) {
return combineWith(rightList, Pair<E, T>::new);
}
@@ -399,8 +398,8 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
* @see bjc.utils.funcdata.IFunctionalList#partition(int)
*/
@Override
- public IFunctionalList<IFunctionalList<E>>
- partition(int numberPerPartition) {
+ public IFunctionalList<IFunctionalList<E>> partition(
+ int numberPerPartition) {
if (numberPerPartition < 1
|| numberPerPartition > wrappedList.size()) {
throw new IllegalArgumentException("" + numberPerPartition
@@ -408,12 +407,11 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
+ wrappedList.size());
}
- IFunctionalList<IFunctionalList<E>> returnedList =
- new FunctionalList<>();
+ IFunctionalList<IFunctionalList<E>> returnedList = new FunctionalList<>();
// The current partition being filled
- IHolder<IFunctionalList<E>> currentPartition =
- new Identity<>(new FunctionalList<>());
+ IHolder<IFunctionalList<E>> currentPartition = new Identity<>(
+ new FunctionalList<>());
this.forEach((element) -> {
if (isPartitionFull(numberPerPartition, currentPartition)) {
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java
index 2c5d2ae..3358da0 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java
@@ -172,8 +172,8 @@ public interface IFunctionalList<ContainedType> {
* The predicate to match by
* @return A list containing all elements that match the predicate
*/
- IFunctionalList<ContainedType>
- getMatching(Predicate<ContainedType> matchPredicate);
+ IFunctionalList<ContainedType> getMatching(
+ Predicate<ContainedType> matchPredicate);
/**
* Retrieve the size of the wrapped list
@@ -200,8 +200,8 @@ public interface IFunctionalList<ContainedType> {
* The function to apply to each element in the list
* @return A new list containing the mapped elements of this list.
*/
- <MappedType> IFunctionalList<MappedType>
- map(Function<ContainedType, MappedType> elementTransformer);
+ <MappedType> IFunctionalList<MappedType> map(
+ Function<ContainedType, MappedType> elementTransformer);
/**
* Zip two lists into a list of pairs
@@ -214,8 +214,8 @@ public interface IFunctionalList<ContainedType> {
* @return A list containing pairs of this element and the specified
* list
*/
- <OtherType> IFunctionalList<IPair<ContainedType, OtherType>>
- pairWith(IFunctionalList<OtherType> rightList);
+ <OtherType> IFunctionalList<IPair<ContainedType, OtherType>> pairWith(
+ IFunctionalList<OtherType> rightList);
/**
* Partition this list into a list of sublists
@@ -224,8 +224,8 @@ public interface IFunctionalList<ContainedType> {
* The size of elements to put into each one of the sublists
* @return A list partitioned into partitions of size nPerPart
*/
- IFunctionalList<IFunctionalList<ContainedType>>
- partition(int numberPerPartition);
+ IFunctionalList<IFunctionalList<ContainedType>> partition(
+ int numberPerPartition);
/**
* Prepend an item to the list
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java
index 866471c..026f3f8 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java
@@ -170,8 +170,8 @@ public interface ITree<ContainedType> {
* The function to use to transform tokens
* @return A tree with the token types transformed
*/
- public <MappedType> ITree<MappedType>
- transformTree(Function<ContainedType, MappedType> transformer);
+ public <MappedType> ITree<MappedType> transformTree(
+ Function<ContainedType, MappedType> transformer);
/**
* Perform an action on each part of the tree
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java
index 6e9d14e..c147646 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java
@@ -179,7 +179,7 @@ public class BinarySearchTree<T> {
} else if (traversalPredicate == null) {
throw new NullPointerException("Predicate must not be nulls");
}
-
+
rootElement.forEach(linearizationMethod, traversalPredicate);
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeNode.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeNode.java
index 58e07f7..371abd4 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeNode.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeNode.java
@@ -1,6 +1,9 @@
package bjc.utils.funcdata.bst;
-import static bjc.utils.funcdata.bst.DirectedWalkFunction.DirectedWalkResult.*;
+import static bjc.utils.funcdata.bst.DirectedWalkFunction.DirectedWalkResult.FAILURE;
+import static bjc.utils.funcdata.bst.DirectedWalkFunction.DirectedWalkResult.LEFT;
+import static bjc.utils.funcdata.bst.DirectedWalkFunction.DirectedWalkResult.RIGHT;
+import static bjc.utils.funcdata.bst.DirectedWalkFunction.DirectedWalkResult.SUCCESS;
import java.util.Comparator;
import java.util.function.BiFunction;
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/TreeLinearizationMethod.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/TreeLinearizationMethod.java
index 6c15284..eedb189 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/TreeLinearizationMethod.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/TreeLinearizationMethod.java
@@ -13,13 +13,13 @@ public enum TreeLinearizationMethod {
*/
INORDER,
/**
- * Visit the left side of this tree part, the right side, and then
- * the tree part itself.
+ * Visit the left side of this tree part, the right side, and then the
+ * tree part itself.
*/
POSTORDER,
/**
- * Visit the tree part itself, then the left side of tthis tree
- * part and then the right part.
+ * Visit the tree part itself, then the left side of tthis tree part
+ * and then the right part.
*/
PREORDER
} \ No newline at end of file