From 58e0022923d573782f5db1f22a1713a98712e37b Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Sat, 13 Mar 2021 10:13:12 -0500 Subject: Update documentation --- .../main/java/bjc/utils/funcutils/LambdaLock.java | 12 ++++++---- .../main/java/bjc/utils/funcutils/ListUtils.java | 25 +++++--------------- .../main/java/bjc/utils/funcutils/SetUtils.java | 8 +++---- .../main/java/bjc/utils/funcutils/TestUtils.java | 27 ++++++++++------------ .../main/java/bjc/utils/funcutils/TreeUtils.java | 7 +++--- 5 files changed, 32 insertions(+), 47 deletions(-) (limited to 'base/src/main/java/bjc/utils/funcutils') 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 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 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 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 List> permuteList(List list) { @@ -343,19 +341,8 @@ public class ListUtils { T elm1 = list.get(0); T elm2 = list.get(1); - List 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 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 Set> powerSet(Set originalSet) { @@ -55,8 +55,8 @@ public class SetUtils { /** * Utility method for set construction. * - * @param elms - * The elements to stick in the set. + * @param 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 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 void assertIteratorEquals(Iterator 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 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 void assertIteratorEquals(boolean hasMore, Iterator 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 The type of the values. + * @param src The list of actual elements. + * @param exps The list of expected elements. */ @SafeVarargs public static void assertListEquals(List 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 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 ListEx> outlineTree(Tree tre, Predicate leafMarker) { -- cgit v1.2.3