summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/funcutils
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcutils')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java4
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java14
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java48
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java6
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenSplitter.java10
5 files changed, 41 insertions, 41 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java
index 67fd5ec..61b13ea 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java
@@ -4,7 +4,7 @@ import java.util.Random;
import java.util.function.Consumer;
import bjc.utils.funcdata.FunctionalList;
-import bjc.utils.funcdata.IFunctionalList;
+import bjc.utils.funcdata.IList;
/**
* Utility methods on enums
@@ -31,7 +31,7 @@ public class EnumUtils {
int nValues, Consumer<E> action, Random rnd) {
E[] enumValues = enumClass.getEnumConstants();
- IFunctionalList<E> valueList = new FunctionalList<>(enumValues);
+ IList<E> valueList = new FunctionalList<>(enumValues);
int randomValueCount = enumValues.length - nValues;
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
index 67cf4b1..34a7ee0 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
@@ -5,7 +5,7 @@ import java.util.function.Function;
import bjc.utils.data.IHolder;
import bjc.utils.funcdata.FunctionalList;
-import bjc.utils.funcdata.IFunctionalList;
+import bjc.utils.funcdata.IList;
/**
* Implements a single group partitioning pass on a list
@@ -16,16 +16,16 @@ import bjc.utils.funcdata.IFunctionalList;
* The type of element in the list being partitioned
*/
final class GroupPartIteration<E> implements Consumer<E> {
- private IFunctionalList<IFunctionalList<E>> returnedList;
- private IHolder<IFunctionalList<E>> currentPartition;
- private IFunctionalList<E> rejectedItems;
+ private IList<IList<E>> returnedList;
+ private IHolder<IList<E>> currentPartition;
+ private IList<E> rejectedItems;
private IHolder<Integer> numberInCurrentPartition;
private int numberPerPartition;
private Function<E, Integer> elementCounter;
- public GroupPartIteration(IFunctionalList<IFunctionalList<E>> returned,
- IHolder<IFunctionalList<E>> currPart,
- IFunctionalList<E> rejects, IHolder<Integer> numInCurrPart,
+ public GroupPartIteration(IList<IList<E>> returned,
+ IHolder<IList<E>> currPart,
+ IList<E> rejects, IHolder<Integer> numInCurrPart,
int nPerPart, Function<E, Integer> eleCount) {
this.returnedList = returned;
this.currentPartition = currPart;
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java
index ea15a78..913ccc4 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java
@@ -8,7 +8,7 @@ import bjc.utils.data.IHolder;
import bjc.utils.data.IPair;
import bjc.utils.data.Identity;
import bjc.utils.funcdata.FunctionalList;
-import bjc.utils.funcdata.IFunctionalList;
+import bjc.utils.funcdata.IList;
/**
* Utilities for manipulating FunctionalLists that don't belong in the
@@ -28,7 +28,7 @@ public class ListUtils {
* The list of tokens to collapse
* @return The collapsed string of tokens
*/
- public static String collapseTokens(IFunctionalList<String> input) {
+ public static String collapseTokens(IList<String> input) {
if (input == null) {
throw new NullPointerException("Input must not be null");
}
@@ -46,7 +46,7 @@ public class ListUtils {
* The seperator to use for seperating tokens
* @return The collapsed string of tokens
*/
- public static String collapseTokens(IFunctionalList<String> input,
+ public static String collapseTokens(IList<String> input,
String seperator) {
if (input == null) {
throw new NullPointerException("Input must not be null");
@@ -78,8 +78,8 @@ public class ListUtils {
* @return The tokens that have been deaffixed
*
*/
- public static IFunctionalList<String> deAffixTokens(
- IFunctionalList<String> input,
+ public static IList<String> deAffixTokens(
+ IList<String> input,
Deque<IPair<String, String>> operators) {
if (input == null) {
throw new NullPointerException("Input must not be null");
@@ -88,7 +88,7 @@ public class ListUtils {
"Set of operators must not be null");
}
- IHolder<IFunctionalList<String>> returnedList = new Identity<>(
+ IHolder<IList<String>> returnedList = new Identity<>(
input);
operators.forEach((operator) -> returnedList
@@ -115,10 +115,10 @@ public class ListUtils {
* selected from the specified list without replacement
*/
- public static <E> IFunctionalList<E> drawWithoutReplacement(
- IFunctionalList<E> list, int numberOfItems,
+ public static <E> IList<E> drawWithoutReplacement(
+ IList<E> list, int numberOfItems,
Function<Integer, Integer> rng) {
- IFunctionalList<E> selectedItems = new FunctionalList<>(
+ IList<E> selectedItems = new FunctionalList<>(
new ArrayList<>(numberOfItems));
int totalItems = list.getSize();
@@ -153,10 +153,10 @@ public class ListUtils {
* @return A new list containing the desired number of items randomly
* selected from the specified list
*/
- public static <E> IFunctionalList<E> drawWithReplacement(
- IFunctionalList<E> list, int numberOfItems,
+ public static <E> IList<E> drawWithReplacement(
+ IList<E> list, int numberOfItems,
Function<Integer, Integer> rng) {
- IFunctionalList<E> selectedItems = new FunctionalList<>(
+ IList<E> selectedItems = new FunctionalList<>(
new ArrayList<>(numberOfItems));
for (int i = 0; i < numberOfItems; i++) {
@@ -181,8 +181,8 @@ public class ListUtils {
* The number of elements to put in each partition
* @return A list partitioned according to the above rules
*/
- public static <E> IFunctionalList<IFunctionalList<E>> groupPartition(
- IFunctionalList<E> input, Function<E, Integer> elementCounter,
+ public static <E> IList<IList<E>> groupPartition(
+ IList<E> input, Function<E, Integer> elementCounter,
int numberPerPartition) {
if (input == null) {
throw new NullPointerException("Input list must not be null");
@@ -199,17 +199,17 @@ public class ListUtils {
/*
* List that holds our results
*/
- IFunctionalList<IFunctionalList<E>> returnedList = new FunctionalList<>();
+ IList<IList<E>> returnedList = new FunctionalList<>();
/*
* List that holds current partition
*/
- IHolder<IFunctionalList<E>> currentPartition = new Identity<>(
+ IHolder<IList<E>> currentPartition = new Identity<>(
new FunctionalList<>());
/*
* List that holds elements rejected during current pass
*/
- IFunctionalList<E> rejectedElements = new FunctionalList<>();
+ IList<E> rejectedElements = new FunctionalList<>();
/*
* The effective number of elements in the current partitition
@@ -254,11 +254,11 @@ public class ListUtils {
* @return A list containing all the elements of the lists
*/
@SafeVarargs
- public static <E> IFunctionalList<E> mergeLists(
- IFunctionalList<E>... lists) {
- IFunctionalList<E> returnedList = new FunctionalList<>();
+ public static <E> IList<E> mergeLists(
+ IList<E>... lists) {
+ IList<E> returnedList = new FunctionalList<>();
- for (IFunctionalList<E> list : lists) {
+ for (IList<E> list : lists) {
list.forEach(returnedList::add);
}
@@ -279,8 +279,8 @@ public class ListUtils {
* @return A list of tokens split on all the operators
*
*/
- public static IFunctionalList<String> splitTokens(
- IFunctionalList<String> input,
+ public static IList<String> splitTokens(
+ IList<String> input,
Deque<IPair<String, String>> operators) {
if (input == null) {
throw new NullPointerException("Input must not be null");
@@ -289,7 +289,7 @@ public class ListUtils {
"Set of operators must not be null");
}
- IHolder<IFunctionalList<String>> returnedList = new Identity<>(
+ IHolder<IList<String>> returnedList = new Identity<>(
input);
operators.forEach((operator) -> {
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java
index 9ea3596..6ed4ecf 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java
@@ -3,10 +3,10 @@ package bjc.utils.funcutils;
import java.util.function.BiFunction;
import bjc.utils.funcdata.FunctionalList;
-import bjc.utils.funcdata.IFunctionalList;
+import bjc.utils.funcdata.IList;
final class TokenDeaffixer
- implements BiFunction<String, String, IFunctionalList<String>> {
+ implements BiFunction<String, String, IList<String>> {
private String token;
public TokenDeaffixer(String tok) {
@@ -14,7 +14,7 @@ final class TokenDeaffixer
}
@Override
- public IFunctionalList<String> apply(String operatorName,
+ public IList<String> apply(String operatorName,
String operatorRegex) {
if (operatorName == null) {
throw new NullPointerException(
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenSplitter.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenSplitter.java
index 68dde25..b9693a7 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenSplitter.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenSplitter.java
@@ -3,10 +3,10 @@ package bjc.utils.funcutils;
import java.util.function.BiFunction;
import bjc.utils.funcdata.FunctionalList;
-import bjc.utils.funcdata.IFunctionalList;
+import bjc.utils.funcdata.IList;
final class TokenSplitter
- implements BiFunction<String, String, IFunctionalList<String>> {
+ implements BiFunction<String, String, IList<String>> {
private String tokenToSplit;
public TokenSplitter(String tok) {
@@ -14,7 +14,7 @@ final class TokenSplitter
}
@Override
- public IFunctionalList<String> apply(String operatorName,
+ public IList<String> apply(String operatorName,
String operatorRegex) {
if (operatorName == null) {
throw new NullPointerException(
@@ -29,10 +29,10 @@ final class TokenSplitter
return new FunctionalList<>(tokenToSplit);
}
- IFunctionalList<String> splitTokens = new FunctionalList<>(
+ IList<String> splitTokens = new FunctionalList<>(
tokenToSplit.split(operatorRegex));
- IFunctionalList<String> result = new FunctionalList<>();
+ IList<String> result = new FunctionalList<>();
int tokenExpansionSize = splitTokens.getSize();