summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/main/java/bjc')
-rw-r--r--base/src/main/java/bjc/utils/funcutils/LambdaLock.java12
-rw-r--r--base/src/main/java/bjc/utils/funcutils/ListUtils.java25
-rw-r--r--base/src/main/java/bjc/utils/funcutils/SetUtils.java8
-rw-r--r--base/src/main/java/bjc/utils/funcutils/TestUtils.java27
-rw-r--r--base/src/main/java/bjc/utils/funcutils/TreeUtils.java7
-rw-r--r--base/src/main/java/bjc/utils/patterns/SimplePatternMatcher.java1
6 files changed, 33 insertions, 47 deletions
diff --git a/base/src/main/java/bjc/utils/funcutils/LambdaLock.java b/base/src/main/java/bjc/utils/funcutils/LambdaLock.java
index f3637f9..c7ba09a 100644
--- a/base/src/main/java/bjc/utils/funcutils/LambdaLock.java
+++ b/base/src/main/java/bjc/utils/funcutils/LambdaLock.java
@@ -36,8 +36,9 @@ public class LambdaLock {
/**
* Execute an action with the read lock taken.
*
- * @param supp
- * The action to call.
+ * @param <T> The type returned by the action.
+ *
+ * @param supp The action to call.
*
* @return The result of the action.
*/
@@ -53,9 +54,10 @@ public class LambdaLock {
/**
* Execute an action with the write lock taken.
- *
- * @param supp
- * The action to call.
+ *
+ * @param <T> The type returned by the action.
+ *
+ * @param supp The action to call.
*
* @return The result of the action.
*/
diff --git a/base/src/main/java/bjc/utils/funcutils/ListUtils.java b/base/src/main/java/bjc/utils/funcutils/ListUtils.java
index 17642ce..ab32ccc 100644
--- a/base/src/main/java/bjc/utils/funcutils/ListUtils.java
+++ b/base/src/main/java/bjc/utils/funcutils/ListUtils.java
@@ -1,9 +1,6 @@
package bjc.utils.funcutils;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
import java.util.function.*;
import bjc.funcdata.FunctionalList;
@@ -321,8 +318,9 @@ public class ListUtils {
*
* This is a version of Algorith P (Plain Changes) from Knuth (vol 4A, pg 322)
*
- * @param list
- * The list to generate permutations from.
+ * @param <T> The type of elements in the list.
+ *
+ * @param list The list to generate permutations from.
* @return The list of permutations of the list.
*/
public static <T> List<List<T>> permuteList(List<T> list) {
@@ -343,19 +341,8 @@ public class ListUtils {
T elm1 = list.get(0);
T elm2 = list.get(1);
- List<T> currPerm = new ArrayList<>(2);
-
- currPerm.add(elm1);
- currPerm.add(elm2);
-
- permutes.add(currPerm);
-
- currPerm = new ArrayList<>(2);
-
- currPerm.add(elm2);
- currPerm.add(elm1);
-
- permutes.add(currPerm);
+ permutes.add(Arrays.asList(elm1, elm2));
+ permutes.add(Arrays.asList(elm2, elm1));
return permutes;
}
diff --git a/base/src/main/java/bjc/utils/funcutils/SetUtils.java b/base/src/main/java/bjc/utils/funcutils/SetUtils.java
index babdb8e..b721d10 100644
--- a/base/src/main/java/bjc/utils/funcutils/SetUtils.java
+++ b/base/src/main/java/bjc/utils/funcutils/SetUtils.java
@@ -15,8 +15,8 @@ public class SetUtils {
/**
* Create a power-set (set of all subsets) of a given set.
*
- * @param originalSet
- * The set to create a power-set of.
+ * @param <T> The type of elements contained in the set.
+ * @param originalSet The set to create a power-set of.
* @return The power-set of the set.
*/
public static <T> Set<Set<T>> powerSet(Set<T> originalSet) {
@@ -55,8 +55,8 @@ public class SetUtils {
/**
* Utility method for set construction.
*
- * @param elms
- * The elements to stick in the set.
+ * @param <T> The type of elements in the set.
+ * @param elms The elements to stick in the set.
* @return A set containing the specified elements.
*/
@SafeVarargs
diff --git a/base/src/main/java/bjc/utils/funcutils/TestUtils.java b/base/src/main/java/bjc/utils/funcutils/TestUtils.java
index c7aeec1..bf38cbe 100644
--- a/base/src/main/java/bjc/utils/funcutils/TestUtils.java
+++ b/base/src/main/java/bjc/utils/funcutils/TestUtils.java
@@ -15,10 +15,9 @@ public class TestUtils {
/**
* Assert an iterator provides a particular sequence of values.
*
- * @param src
- * The iterator to pull values from.
- * @param vals
- * The values to expect from the iterator.
+ * @param <T> The type of the values.
+ * @param src The iterator to pull values from.
+ * @param vals The values to expect from the iterator.
*/
@SafeVarargs
public static <T> void assertIteratorEquals(Iterator<T> src, T... vals) {
@@ -28,12 +27,10 @@ public class TestUtils {
/**
* Assert an iterator provides a particular sequence of values.
*
- * @param src
- * The iterator to pull values from.
- * @param hasMore
- * The expected value of hasNext for the iterator.
- * @param vals
- * The values to expect from the iterator.
+ * @param <T> The type of the values.
+ * @param src The iterator to pull values from.
+ * @param hasMore The expected value of hasNext for the iterator.
+ * @param vals The values to expect from the iterator.
*/
@SafeVarargs
public static <T> void assertIteratorEquals(boolean hasMore, Iterator<T> src,
@@ -44,6 +41,8 @@ public class TestUtils {
* Even though it's awkward, the boolean has to come first. Otherwise, there are
* cases where the compiler will get confused as to what the right value for T
* is, and be unable to pick an overload.
+ *
+ * This is a case where named parameter would be rather useful.
*/
assertIteratorEquals(src, vals);
@@ -53,11 +52,9 @@ public class TestUtils {
/**
* Assert that a list has a given set of contents.
*
- * @param src
- * The list of actual elements.
- *
- * @param exps
- * The list of expected elements.
+ * @param <T> The type of the values.
+ * @param src The list of actual elements.
+ * @param exps The list of expected elements.
*/
@SafeVarargs
public static <T> void assertListEquals(List<T> src, T... exps) {
diff --git a/base/src/main/java/bjc/utils/funcutils/TreeUtils.java b/base/src/main/java/bjc/utils/funcutils/TreeUtils.java
index 41a01d8..5a1d9c8 100644
--- a/base/src/main/java/bjc/utils/funcutils/TreeUtils.java
+++ b/base/src/main/java/bjc/utils/funcutils/TreeUtils.java
@@ -15,10 +15,9 @@ public class TreeUtils {
/**
* Convert a tree into a list of outline nodes that match a certain path.
*
- * @param tre
- * The tree to outline.
- * @param leafMarker
- * The path to mark nodes with.
+ * @param <T> The type of the values.
+ * @param tre The tree to outline.
+ * @param leafMarker The path to mark nodes with.
* @return The list of marked paths.
*/
public static <T> ListEx<ListEx<T>> outlineTree(Tree<T> tre, Predicate<T> leafMarker) {
diff --git a/base/src/main/java/bjc/utils/patterns/SimplePatternMatcher.java b/base/src/main/java/bjc/utils/patterns/SimplePatternMatcher.java
index fea947a..9fae976 100644
--- a/base/src/main/java/bjc/utils/patterns/SimplePatternMatcher.java
+++ b/base/src/main/java/bjc/utils/patterns/SimplePatternMatcher.java
@@ -7,6 +7,7 @@ import bjc.data.*;
*
* @author Ben Culkin
*
+ * @param <InputType> The type input to the pattern matcher.
* @param <ReturnType> The type returned by the pattern.
*/
public class SimplePatternMatcher<ReturnType, InputType>