From 504ca816530efdff06bc202e0432ebd354aec304 Mon Sep 17 00:00:00 2001 From: EVE Date: Tue, 14 Mar 2017 12:07:14 -0400 Subject: Cleanup --- .../main/java/bjc/utils/funcdata/ExtendedMap.java | 12 +- .../java/bjc/utils/funcdata/FunctionalList.java | 131 ++++++++------------- .../java/bjc/utils/funcdata/FunctionalMap.java | 31 ++--- .../utils/funcdata/FunctionalStringTokenizer.java | 56 ++++----- .../src/main/java/bjc/utils/funcdata/IList.java | 77 ++++++------ .../src/main/java/bjc/utils/funcdata/IMap.java | 40 +++---- .../main/java/bjc/utils/funcdata/SentryList.java | 4 +- .../bjc/utils/funcdata/TransformedValueMap.java | 6 +- .../bjc/utils/funcdata/bst/BinarySearchTree.java | 44 ++++--- .../utils/funcdata/bst/BinarySearchTreeLeaf.java | 20 ++-- .../utils/funcdata/bst/BinarySearchTreeNode.java | 106 ++++++----------- .../utils/funcdata/bst/DirectedWalkFunction.java | 8 +- .../java/bjc/utils/funcdata/bst/ITreePart.java | 18 +-- .../funcdata/bst/TreeLinearizationMethod.java | 2 +- .../java/bjc/utils/funcdata/theory/Bifunctor.java | 12 +- .../java/bjc/utils/funcdata/theory/Functor.java | 8 +- .../bjc/utils/funcdata/theory/package-info.java | 2 +- 17 files changed, 238 insertions(+), 339 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java index 7e6c23b..7db6cea 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java @@ -1,11 +1,11 @@ package bjc.utils.funcdata; +import bjc.utils.funcutils.ListUtils; + import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; -import bjc.utils.funcutils.ListUtils; - class ExtendedMap implements IMap { private IMap delegate; @@ -23,9 +23,7 @@ class ExtendedMap implements IMap { @Override public boolean containsKey(KeyType key) { - if (store.containsKey(key)) { - return true; - } + if(store.containsKey(key)) return true; return delegate.containsKey(key); } @@ -58,9 +56,7 @@ class ExtendedMap implements IMap { @Override public ValueType get(KeyType key) { - if (store.containsKey(key)) { - return store.get(key); - } + if(store.containsKey(key)) return store.get(key); return delegate.get(key); } 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 f98f32c..1e52d05 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,10 @@ package bjc.utils.funcdata; +import bjc.utils.data.IHolder; +import bjc.utils.data.IPair; +import bjc.utils.data.Identity; +import bjc.utils.data.Pair; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -12,18 +17,13 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; -import bjc.utils.data.IHolder; -import bjc.utils.data.IPair; -import bjc.utils.data.Identity; -import bjc.utils.data.Pair; - /** * A wrapper over another list that provides eager functional operations over * it. * * Differs from a stream in every way except for the fact that they both provide * functional operations. - * + * * @author ben * * @param @@ -44,9 +44,9 @@ public class FunctionalList implements Cloneable, IList { /** * Create a new functional list containing the specified items. - * + * * Takes O(n) time, where n is the number of items specified - * + * * @param items * The items to put into this functional list. */ @@ -54,14 +54,14 @@ public class FunctionalList implements Cloneable, IList { public FunctionalList(E... items) { wrapped = new ArrayList<>(items.length); - for (E item : items) { + for(E item : items) { wrapped.add(item); } } /** * Create a new functional list with the specified size. - * + * * @param size * The size of the backing list . */ @@ -71,16 +71,14 @@ public class FunctionalList implements Cloneable, IList { /** * Create a new functional list as a wrapper of a existing list. - * + * * Takes O(1) time, since it doesn't copy the list. - * + * * @param backing * The list to use as a backing list. */ public FunctionalList(List backing) { - if (backing == null) { - throw new NullPointerException("Backing list must be non-null"); - } + if(backing == null) throw new NullPointerException("Backing list must be non-null"); wrapped = backing; } @@ -92,15 +90,12 @@ public class FunctionalList implements Cloneable, IList { @Override public boolean allMatch(Predicate predicate) { - if (predicate == null) { - throw new NullPointerException("Predicate must be non-null"); - } + if(predicate == null) throw new NullPointerException("Predicate must be non-null"); - for (E item : wrapped) { - if (!predicate.test(item)) { - // We've found a non-matching item + for(E item : wrapped) { + if(!predicate.test(item)) // We've found a non-matching + // item return false; - } } // All of the items matched @@ -109,15 +104,11 @@ public class FunctionalList implements Cloneable, IList { @Override public boolean anyMatch(Predicate predicate) { - if (predicate == null) { - throw new NullPointerException("Predicate must be not null"); - } + if(predicate == null) throw new NullPointerException("Predicate must be not null"); - for (E item : wrapped) { - if (predicate.test(item)) { - // We've found a matching item + for(E item : wrapped) { + if(predicate.test(item)) // We've found a matching item return true; - } } // We didn't find a matching item @@ -126,16 +117,16 @@ public class FunctionalList implements Cloneable, IList { /** * Clone this list into a new one, and clone the backing list as well - * + * * Takes O(n) time, where n is the number of elements in the list - * + * * @return A list */ @Override public IList clone() { IList cloned = new FunctionalList<>(); - for (E element : wrapped) { + for(E element : wrapped) { cloned.add(element); } @@ -144,19 +135,16 @@ public class FunctionalList implements Cloneable, IList { @Override public IList combineWith(IList rightList, BiFunction itemCombiner) { - if (rightList == null) { + if(rightList == null) throw new NullPointerException("Target combine list must not be null"); - } else if (itemCombiner == null) { - throw new NullPointerException("Combiner must not be null"); - } + else if(itemCombiner == null) throw new NullPointerException("Combiner must not be null"); IList returned = new FunctionalList<>(); // Get the iterator for the other list Iterator rightIterator = rightList.toIterable().iterator(); - for (Iterator leftIterator = wrapped.iterator(); leftIterator.hasNext() - && rightIterator.hasNext();) { + for(Iterator leftIterator = wrapped.iterator(); leftIterator.hasNext() && rightIterator.hasNext();) { // Add the transformed items to the result list E leftVal = leftIterator.next(); T rightVal = rightIterator.next(); @@ -175,27 +163,21 @@ public class FunctionalList implements Cloneable, IList { @Override public E first() { - if (wrapped.size() < 1) { - throw new NoSuchElementException("Attempted to get first element of empty list"); - } + if(wrapped.size() < 1) throw new NoSuchElementException("Attempted to get first element of empty list"); return wrapped.get(0); } @Override public IList flatMap(Function> expander) { - if (expander == null) { - throw new NullPointerException("Expander must not be null"); - } + if(expander == null) throw new NullPointerException("Expander must not be null"); IList returned = new FunctionalList<>(this.wrapped.size()); forEach(element -> { IList expandedElement = expander.apply(element); - if (expandedElement == null) { - throw new NullPointerException("Expander returned null list"); - } + if(expandedElement == null) throw new NullPointerException("Expander returned null list"); // Add each element to the returned list expandedElement.forEach(returned::add); @@ -204,19 +186,16 @@ public class FunctionalList implements Cloneable, IList { return returned; } + @Override public void forEach(Consumer action) { - if (action == null) { - throw new NullPointerException("Action is null"); - } + if(action == null) throw new NullPointerException("Action is null"); wrapped.forEach(action); } @Override public void forEachIndexed(BiConsumer indexedAction) { - if (indexedAction == null) { - throw new NullPointerException("Action must not be null"); - } + if(indexedAction == null) throw new NullPointerException("Action must not be null"); // This is held b/c ref'd variables must be final/effectively // final @@ -238,7 +217,7 @@ public class FunctionalList implements Cloneable, IList { /** * Get the internal backing list. - * + * * @return The backing list this list is based off of. */ public List getInternal() { @@ -247,14 +226,12 @@ public class FunctionalList implements Cloneable, IList { @Override public IList getMatching(Predicate predicate) { - if (predicate == null) { - throw new NullPointerException("Predicate must not be null"); - } + if(predicate == null) throw new NullPointerException("Predicate must not be null"); IList returned = new FunctionalList<>(); wrapped.forEach((element) -> { - if (predicate.test(element)) { + if(predicate.test(element)) { // The item matches, so add it to the returned // list returned.add(element); @@ -283,9 +260,7 @@ public class FunctionalList implements Cloneable, IList { @Override public IList map(Function elementTransformer) { - if (elementTransformer == null) { - throw new NullPointerException("Transformer must be not null"); - } + if(elementTransformer == null) throw new NullPointerException("Transformer must be not null"); IList returned = new FunctionalList<>(this.wrapped.size()); @@ -304,10 +279,9 @@ public class FunctionalList implements Cloneable, IList { @Override public IList> partition(int numberPerPartition) { - if (numberPerPartition < 1 || numberPerPartition > wrapped.size()) { + if(numberPerPartition < 1 || numberPerPartition > wrapped.size()) throw new IllegalArgumentException("" + numberPerPartition + " is an invalid partition size. Must be between 1 and " + wrapped.size()); - } IList> returned = new FunctionalList<>(); @@ -315,7 +289,7 @@ public class FunctionalList implements Cloneable, IList { IHolder> currentPartition = new Identity<>(new FunctionalList<>()); this.forEach((element) -> { - if (isPartitionFull(numberPerPartition, currentPartition)) { + if(isPartitionFull(numberPerPartition, currentPartition)) { // Add the partition to the list returned.add(currentPartition.unwrap((partition) -> partition)); @@ -337,9 +311,7 @@ public class FunctionalList implements Cloneable, IList { @Override public E randItem(Function rnd) { - if (rnd == null) { - throw new NullPointerException("Random source must not be null"); - } + if(rnd == null) throw new NullPointerException("Random source must not be null"); int randomIndex = rnd.apply(wrapped.size()); @@ -349,11 +321,9 @@ public class FunctionalList implements Cloneable, IList { @Override public F reduceAux(T initialValue, BiFunction stateAccumulator, Function resultTransformer) { - if (stateAccumulator == null) { + if(stateAccumulator == null) throw new NullPointerException("Accumulator must not be null"); - } else if (resultTransformer == null) { - throw new NullPointerException("Transformer must not be null"); - } + else if(resultTransformer == null) throw new NullPointerException("Transformer must not be null"); // The current collapsed list IHolder currentState = new Identity<>(initialValue); @@ -369,9 +339,7 @@ public class FunctionalList implements Cloneable, IList { @Override public boolean removeIf(Predicate removePredicate) { - if (removePredicate == null) { - throw new NullPointerException("Predicate must be non-null"); - } + if(removePredicate == null) throw new NullPointerException("Predicate must be non-null"); return wrapped.removeIf(removePredicate); } @@ -391,10 +359,8 @@ public class FunctionalList implements Cloneable, IList { // Search our internal list int foundIndex = Collections.binarySearch(wrapped, searchKey, comparator); - if (foundIndex >= 0) { - // We found a matching element + if(foundIndex >= 0) // We found a matching element return wrapped.get(foundIndex); - } // We didn't find an element return null; @@ -425,22 +391,19 @@ public class FunctionalList implements Cloneable, IList { public String toString() { int lSize = getSize(); - if (lSize == 0) - return "()"; + if(lSize == 0) return "()"; StringBuilder sb = new StringBuilder("("); Iterator itr = toIterable().iterator(); E itm = itr.next(); int i = 0; - if (lSize == 1) { - return "(" + itm + ")"; - } + if(lSize == 1) return "(" + itm + ")"; - for (E item : toIterable()) { + for(E item : toIterable()) { sb.append(item.toString()); - if (i < lSize - 1) { + if(i < lSize - 1) { sb.append(", "); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java index 3d3fed1..10a727c 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java @@ -1,16 +1,16 @@ package bjc.utils.funcdata; +import bjc.utils.data.IPair; + import java.util.HashMap; import java.util.Map; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; -import bjc.utils.data.IPair; - /** * Basic implementation of {@link IMap} - * + * * @author ben * * @param @@ -30,7 +30,7 @@ public class FunctionalMap implements IMap implements IMap... entries) { this(); - for (IPair entry : entries) { + for(IPair entry : entries) { entry.doWith((key, val) -> { wrappedMap.put(key, val); }); @@ -47,14 +47,12 @@ public class FunctionalMap implements IMap wrap) { - if (wrap == null) { - throw new NullPointerException("Map to wrap must not be null"); - } + if(wrap == null) throw new NullPointerException("Map to wrap must not be null"); wrappedMap = wrap; } @@ -91,13 +89,10 @@ public class FunctionalMap implements IMap implements IMap IMap mapValues(Function transformer) { - if (transformer == null) { - throw new NullPointerException("Transformer must not be null"); - } + if(transformer == null) throw new NullPointerException("Transformer must not be null"); return new TransformedValueMap<>(this, transformer); } @Override public ValueType put(KeyType key, ValueType val) { - if (key == null) { - throw new NullPointerException("Key must not be null"); - } + if(key == null) throw new NullPointerException("Key must not be null"); return wrappedMap.put(key, val); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java index 93f2dca..b7e3f30 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java @@ -6,22 +6,20 @@ import java.util.function.Function; /** * A string tokenizer that exposes a functional interface - * + * * @author ben * */ public class FunctionalStringTokenizer { /** * Create a new tokenizer from the specified string. - * + * * @param strang * The string to create a tokenizer from. * @return A new tokenizer that splits the provided string on spaces. */ public static FunctionalStringTokenizer fromString(String strang) { - if (strang == null) { - throw new NullPointerException("String to tokenize must be non-null"); - } + if(strang == null) throw new NullPointerException("String to tokenize must be non-null"); return new FunctionalStringTokenizer(new StringTokenizer(strang, " ")); } @@ -33,14 +31,12 @@ public class FunctionalStringTokenizer { /** * Create a functional string tokenizer from a given string - * + * * @param inp * The string to tokenize */ public FunctionalStringTokenizer(String inp) { - if (inp == null) { - throw new NullPointerException("String to tokenize must be non-null"); - } + if(inp == null) throw new NullPointerException("String to tokenize must be non-null"); this.input = new StringTokenizer(inp); } @@ -48,55 +44,49 @@ public class FunctionalStringTokenizer { /** * Create a functional string tokenizer from a given string and set of * separators - * + * * @param input * The string to tokenize * @param seperators * The set of separating tokens to use for splitting */ public FunctionalStringTokenizer(String input, String seperators) { - if (input == null) { + if(input == null) throw new NullPointerException("String to tokenize must not be null"); - } else if (seperators == null) { - throw new NullPointerException("Tokens to split on must not be null"); - } + else if(seperators == null) throw new NullPointerException("Tokens to split on must not be null"); this.input = new StringTokenizer(input, seperators); } /** * Create a functional string tokenizer from a non-functional one - * + * * @param toWrap * The non-functional string tokenizer to wrap */ public FunctionalStringTokenizer(StringTokenizer toWrap) { - if (toWrap == null) { - throw new NullPointerException("Wrapped tokenizer must not be null"); - } + if(toWrap == null) throw new NullPointerException("Wrapped tokenizer must not be null"); this.input = toWrap; } /** * Execute a provided action for each of the remaining tokens - * + * * @param action * The action to execute for each token */ public void forEachToken(Consumer action) { - if (action == null) { - throw new NullPointerException("Action must not be null"); - } + if(action == null) throw new NullPointerException("Action must not be null"); - while (input.hasMoreTokens()) { + while(input.hasMoreTokens()) { action.accept(input.nextToken()); } } /** * Get the string tokenizer encapsulated by this tokenizer - * + * * @return The encapsulated tokenizer */ public StringTokenizer getInternal() { @@ -105,7 +95,7 @@ public class FunctionalStringTokenizer { /** * Check if this tokenizer has more tokens - * + * * @return Whether or not this tokenizer has more tokens */ public boolean hasMoreTokens() { @@ -116,14 +106,12 @@ public class FunctionalStringTokenizer { * Return the next token from the tokenizer. * * Returns null if no more tokens are available - * + * * @return The next token from the tokenizer */ public String nextToken() { - if (input.hasMoreTokens()) { - // Return the next available token + if(input.hasMoreTokens()) // Return the next available token return input.nextToken(); - } // Return no token return null; @@ -131,7 +119,7 @@ public class FunctionalStringTokenizer { /** * Convert this tokenizer into a list of strings - * + * * @return This tokenizer, converted into a list of strings */ public IList toList() { @@ -141,18 +129,16 @@ public class FunctionalStringTokenizer { /** * Convert the contents of this tokenizer into a list. Consumes all of * the input from this tokenizer. - * + * * @param * The type of the converted tokens - * + * * @param transformer * The function to use to convert tokens. * @return A list containing all of the converted tokens. */ public IList toList(Function transformer) { - if (transformer == null) { - throw new NullPointerException("Transformer must not be null"); - } + if(transformer == null) throw new NullPointerException("Transformer must not be null"); IList returned = new FunctionalList<>(); diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java index 0feaf06..95f4813 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java @@ -1,5 +1,7 @@ package bjc.utils.funcdata; +import bjc.utils.data.IPair; + import java.util.Comparator; import java.util.Iterator; import java.util.function.BiConsumer; @@ -9,11 +11,9 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collector; -import bjc.utils.data.IPair; - /** * A wrapper over another list that provides functional operations over it. - * + * * @author ben * * @param @@ -22,7 +22,7 @@ import bjc.utils.data.IPair; public interface IList extends Iterable { /** * Add an item to this list - * + * * @param item * The item to add to this list. * @return Whether the item was added to the list successfully. @@ -31,7 +31,7 @@ public interface IList extends Iterable { /** * Add all of the elements in the provided list to this list - * + * * @param items * The list of items to add * @return True if every item was successfully added to the list, false @@ -44,7 +44,7 @@ public interface IList extends Iterable { /** * Check if all of the elements of this list match the specified * predicate. - * + * * @param matcher * The predicate to use for checking. * @return Whether all of the elements of the list match the specified @@ -54,7 +54,7 @@ public interface IList extends Iterable { /** * Check if any of the elements in this list match the specified list. - * + * * @param matcher * The predicate to use for checking. * @return Whether any element in the list matches the provided @@ -64,7 +64,7 @@ public interface IList extends Iterable { /** * Reduce the contents of this list using a collector - * + * * @param * The intermediate accumulation type * @param @@ -90,15 +90,15 @@ public interface IList extends Iterable { * * Works sort of like a combined zip/map over resulting pairs. Does not * change the underlying list. - * + * * NOTE: The returned list will have the length of the shorter of this * list and the combined one. - * + * * @param * The type of the second list * @param * The type of the combined list - * + * * @param list * The list to combine with * @param combiner @@ -110,7 +110,7 @@ public interface IList extends Iterable { /** * Check if the list contains the specified item - * + * * @param item * The item to see if it is contained * @return Whether or not the specified item is in the list @@ -119,7 +119,7 @@ public interface IList extends Iterable { /** * Get the first element in the list - * + * * @return The first element in this list. */ ContainedType first(); @@ -129,10 +129,10 @@ public interface IList extends Iterable { * results. * * Does not change the underlying list. - * + * * @param * The type of the flattened list - * + * * @param expander * The function to apply to each member of the list. * @return A new list containing the flattened results of applying the @@ -142,15 +142,16 @@ public interface IList extends Iterable { /** * Apply a given action for each member of the list - * + * * @param action * The action to apply to each member of the list. */ + @Override void forEach(Consumer action); /** * Apply a given function to each element in the list and its index. - * + * * @param action * The function to apply to each element in the list and * its index. @@ -159,7 +160,7 @@ public interface IList extends Iterable { /** * Retrieve a value in the list by its index. - * + * * @param index * The index to retrieve a value from. * @return The value at the specified index in the list. @@ -168,7 +169,7 @@ public interface IList extends Iterable { /** * Retrieve a list containing all elements matching a predicate - * + * * @param predicate * The predicate to match by * @return A list containing all elements that match the predicate @@ -177,14 +178,14 @@ public interface IList extends Iterable { /** * Retrieve the size of the wrapped list - * + * * @return The size of the wrapped list */ int getSize(); /** * Check if this list is empty. - * + * * @return Whether or not this list is empty. */ boolean isEmpty(); @@ -194,10 +195,10 @@ public interface IList extends Iterable { * the list. * * Does not change the underlying list. - * + * * @param * The type of the transformed list - * + * * @param transformer * The function to apply to each element in the list * @return A new list containing the mapped elements of this list. @@ -206,10 +207,10 @@ public interface IList extends Iterable { /** * Zip two lists into a list of pairs - * + * * @param * The type of the second list - * + * * @param list * The list to use as the left side of the pair * @return A list containing pairs of this element and the specified @@ -219,7 +220,7 @@ public interface IList extends Iterable { /** * Partition this list into a list of sublists - * + * * @param partitionSize * The size of elements to put into each one of the * sublists @@ -229,7 +230,7 @@ public interface IList extends Iterable { /** * Prepend an item to the list - * + * * @param item * The item to prepend to the list */ @@ -238,7 +239,7 @@ public interface IList extends Iterable { /** * Select a random item from the list, using a default random number * generator - * + * * @return A random item from the list */ default ContainedType randItem() { @@ -248,7 +249,7 @@ public interface IList extends Iterable { /** * Select a random item from this list, using the provided random number * generator. - * + * * @param rnd * The random number generator to use. * @return A random element from this list. @@ -257,12 +258,12 @@ public interface IList extends Iterable { /** * Reduce this list to a single value, using a accumulative approach. - * + * * @param * The in-between type of the values * @param * The final value type - * + * * @param initial * The initial value of the accumulative state. * @param accumulator @@ -280,7 +281,7 @@ public interface IList extends Iterable { /** * Remove all elements that match a given predicate - * + * * @param predicate * The predicate to use to determine elements to delete * @return Whether there was anything that satisfied the predicate @@ -289,7 +290,7 @@ public interface IList extends Iterable { /** * Remove all parameters that match a given parameter - * + * * @param element * The object to remove all matching copies of */ @@ -306,7 +307,7 @@ public interface IList extends Iterable { * * Since this IS a binary search, the list must have been sorted before * hand. - * + * * @param key * The key to search for. * @param comparator @@ -321,7 +322,7 @@ public interface IList extends Iterable { * elements. * * Does change the underlying list. - * + * * @param comparator * The way to compare elements for sorting. Pass null to * use E's natural ordering @@ -330,14 +331,14 @@ public interface IList extends Iterable { /** * Get the tail of this list (the list without the first element - * + * * @return The list without the first element */ IList tail(); /** * Convert this list into an array - * + * * @param type * The type of array to return * @return The list, as an array @@ -346,7 +347,7 @@ public interface IList extends Iterable { /** * Convert the list into a Iterable - * + * * @return An iterable view onto the list */ Iterable toIterable(); diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java index ff8f973..d83b5c2 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java @@ -6,9 +6,9 @@ import java.util.function.Function; /** * Functional wrapper over map providing some useful things - * + * * @author ben - * + * * @param * The type of this map's keys * @param @@ -23,7 +23,7 @@ public interface IMap { /** * Check if this map contains the specified key - * + * * @param key * The key to check * @return Whether or not the map contains the key @@ -33,14 +33,14 @@ public interface IMap { /** * Extends this map, creating a new map that will delegate queries to * the map, but store any added values itself - * + * * @return An extended map */ IMap extend(); /** * Execute an action for each entry in the map - * + * * @param action * the action to execute for each entry in the map */ @@ -48,7 +48,7 @@ public interface IMap { /** * Perform an action for each key in the map - * + * * @param action * The action to perform on each key in the map */ @@ -56,7 +56,7 @@ public interface IMap { /** * Perform an action for each value in the map - * + * * @param action * The action to perform on each value in the map */ @@ -64,19 +64,19 @@ public interface IMap { /** * Get the value assigned to the given key - * + * * @param key * The key to look for a value under * @return The value of the key - * - * + * + * */ ValueType get(KeyType key); /** * Get a value from the map, and return a default value if the key * doesn't exist - * + * * @param key * The key to attempt to retrieve * @param defaultValue @@ -87,7 +87,7 @@ public interface IMap { default ValueType getOrDefault(KeyType key, ValueType defaultValue) { try { return get(key); - } catch (IllegalArgumentException iaex) { + } catch(IllegalArgumentException iaex) { // We don't care about this, because it indicates a key // is // missing @@ -97,25 +97,25 @@ public interface IMap { /** * Get the number of entries in this map - * + * * @return The number of entries in this map */ int getSize(); /** * Get a list of all the keys in this map - * + * * @return A list of all the keys in this map */ IList keyList(); /** * Transform the values returned by this map. - * + * * NOTE: This transform is applied once for each lookup of a value, so * the transform passed should be a proper function, or things will * likely not work as expected. - * + * * @param * The new type of returned values * @param transformer @@ -126,7 +126,7 @@ public interface IMap { /** * Add an entry to the map - * + * * @param key * The key to put the value under * @param val @@ -134,7 +134,7 @@ public interface IMap { * @return The previous value of the key in the map, or null if the key * wasn't in the map. However, note that it may also return null * if the key was set to null. - * + * * @throws UnsupportedOperationException * if the map implementation doesn't support modifying * the map @@ -143,7 +143,7 @@ public interface IMap { /** * Remove the value bound to the key - * + * * @param key * The key to remove from the map * @return The previous value for the key in the map, or null if the key @@ -155,7 +155,7 @@ public interface IMap { /** * Get a list of the values in this map - * + * * @return A list of values in this map */ IList valueList(); diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/SentryList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/SentryList.java index 32ec7cd..060f69e 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/SentryList.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/SentryList.java @@ -11,11 +11,13 @@ public class SentryList extends FunctionalList { super(backing); } + @Override public boolean add(T item) { boolean val = super.add(item); - if (val) + if(val) { System.out.println("Added item (" + item + ") to list"); + } return val; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java index 36bfaab..d4e1762 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java @@ -6,7 +6,7 @@ import java.util.function.Function; /** * A map that transforms values from one type to another - * + * * @author ben * * @param @@ -17,8 +17,8 @@ import java.util.function.Function; * The type of the transformed values */ final class TransformedValueMap implements IMap { - private IMap backing; - private Function transformer; + private IMap backing; + private Function transformer; public TransformedValueMap(IMap backingMap, Function transform) { backing = backingMap; 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 b3772a4..060b3f5 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 @@ -1,16 +1,16 @@ package bjc.utils.funcdata.bst; +import bjc.utils.funcdata.FunctionalList; +import bjc.utils.funcdata.IList; + import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.function.Predicate; -import bjc.utils.funcdata.FunctionalList; -import bjc.utils.funcdata.IList; - /** * A binary search tree, with some mild support for functional traversal. - * + * * @author ben * * @param @@ -34,14 +34,12 @@ public class BinarySearchTree { /** * Create a new tree using the specified way to compare elements. - * + * * @param cmp * The thing to use for comparing elements */ public BinarySearchTree(Comparator cmp) { - if (cmp == null) { - throw new NullPointerException("Comparator must not be null"); - } + if(cmp == null) throw new NullPointerException("Comparator must not be null"); elementCount = 0; comparator = cmp; @@ -49,14 +47,14 @@ public class BinarySearchTree { /** * Add a node to the binary search tree. - * + * * @param element * The data to add to the binary search tree. */ public void addNode(T element) { elementCount++; - if (root == null) { + if(root == null) { root = new BinarySearchTreeNode<>(element, null, null); } else { root.add(element, comparator); @@ -65,7 +63,7 @@ public class BinarySearchTree { /** * Check if an adjusted pivot falls with the bounds of a list - * + * * @param elements * The list to get bounds from * @param pivot @@ -75,7 +73,7 @@ public class BinarySearchTree { * @return Whether the adjusted pivot is with the list */ private boolean adjustedPivotInBounds(IList elements, int pivot, int pivotAdjustment) { - return (pivot - pivotAdjustment) >= 0 && (pivot + pivotAdjustment) < elements.getSize(); + return pivot - pivotAdjustment >= 0 && pivot + pivotAdjustment < elements.getSize(); } /** @@ -97,8 +95,8 @@ public class BinarySearchTree { int pivotAdjustment = 0; // Add elements until there aren't any left - while (adjustedPivotInBounds(elements, pivot, pivotAdjustment)) { - if (root == null) { + while(adjustedPivotInBounds(elements, pivot, pivotAdjustment)) { + if(root == null) { // Create a new root element root = new BinarySearchTreeNode<>(elements.getByIndex(pivot), null, null); } else { @@ -114,9 +112,9 @@ public class BinarySearchTree { } // Add any trailing unbalanced elements - if ((pivot - pivotAdjustment) >= 0) { + if(pivot - pivotAdjustment >= 0) { root.add(elements.getByIndex(pivot - pivotAdjustment), comparator); - } else if ((pivot + pivotAdjustment) < elements.getSize()) { + } else if(pivot + pivotAdjustment < elements.getSize()) { root.add(elements.getByIndex(pivot + pivotAdjustment), comparator); } } @@ -126,7 +124,7 @@ public class BinarySearchTree { * * Soft-deleted nodes stay in the tree until trim()/balance() is * invoked, and are not included in traversals/finds. - * + * * @param element * The node to delete */ @@ -138,7 +136,7 @@ public class BinarySearchTree { /** * Get the root of the tree. - * + * * @return The root of the tree. */ public ITreePart getRoot() { @@ -147,7 +145,7 @@ public class BinarySearchTree { /** * Check if a node is in the tree - * + * * @param element * The node to check the presence of for the tree. * @return Whether or not the node is in the tree. @@ -158,18 +156,16 @@ public class BinarySearchTree { /** * Traverse the tree in a specified way until the function fails - * + * * @param linearizationMethod * The way to linearize the tree for traversal * @param traversalPredicate * The function to use until it fails */ public void traverse(TreeLinearizationMethod linearizationMethod, Predicate traversalPredicate) { - if (linearizationMethod == null) { + if(linearizationMethod == null) throw new NullPointerException("Linearization method must not be null"); - } else if (traversalPredicate == null) { - throw new NullPointerException("Predicate must not be nulls"); - } + else if(traversalPredicate == null) throw new NullPointerException("Predicate must not be nulls"); root.forEach(linearizationMethod, traversalPredicate); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java index 04765b4..2696577 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java @@ -7,7 +7,7 @@ import java.util.function.Predicate; /** * A leaf in a tree. - * + * * @author ben * * @param @@ -26,7 +26,7 @@ public class BinarySearchTreeLeaf implements ITreePart { /** * Create a new leaf holding the specified data. - * + * * @param element * The data for the leaf to hold. */ @@ -41,9 +41,7 @@ public class BinarySearchTreeLeaf implements ITreePart { @Override public E collapse(Function leafTransformer, BiFunction branchCollapser) { - if (leafTransformer == null) { - throw new NullPointerException("Transformer must not be null"); - } + if(leafTransformer == null) throw new NullPointerException("Transformer must not be null"); return leafTransformer.apply(data); } @@ -60,18 +58,16 @@ public class BinarySearchTreeLeaf implements ITreePart { @Override public void delete(T element, Comparator comparator) { - if (data.equals(element)) { + if(data.equals(element)) { isDeleted = true; } } @Override public boolean directedWalk(DirectedWalkFunction treeWalker) { - if (treeWalker == null) { - throw new NullPointerException("Tree walker must not be null"); - } + if(treeWalker == null) throw new NullPointerException("Tree walker must not be null"); - switch (treeWalker.walk(data)) { + switch(treeWalker.walk(data)) { case SUCCESS: return true; // We don't have any children to care about @@ -85,9 +81,7 @@ public class BinarySearchTreeLeaf implements ITreePart { @Override public boolean forEach(TreeLinearizationMethod linearizationMethod, Predicate traversalPredicate) { - if (traversalPredicate == null) { - throw new NullPointerException("Predicate must not be null"); - } + if(traversalPredicate == null) throw new NullPointerException("Predicate must not be null"); return traversalPredicate.test(data); } 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 46a89f2..4fe9de3 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,18 +1,18 @@ package bjc.utils.funcdata.bst; -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; import java.util.function.Function; import java.util.function.Predicate; +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; + /** * A binary node in a tree. - * + * * @author ben * * @param @@ -31,7 +31,7 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { /** * Create a new node with the specified data and children. - * + * * @param element * The data to store in this node. * @param lft @@ -47,27 +47,24 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { @Override public void add(T element, Comparator comparator) { - if (comparator == null) { - throw new NullPointerException("Comparator must not be null"); - } + if(comparator == null) throw new NullPointerException("Comparator must not be null"); - switch (comparator.compare(data, element)) { + switch(comparator.compare(data, element)) { case -1: - if (left == null) { + if(left == null) { left = new BinarySearchTreeNode<>(element, null, null); } else { left.add(element, comparator); } break; case 0: - if (isDeleted) { + if(isDeleted) { isDeleted = false; - } else { + } else throw new IllegalArgumentException("Can't add duplicate values"); - } break; case 1: - if (right == null) { + if(right == null) { right = new BinarySearchTreeNode<>(element, null, null); } else { right.add(element, comparator); @@ -80,16 +77,15 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { @Override public E collapse(Function nodeCollapser, BiFunction branchCollapser) { - if (nodeCollapser == null || branchCollapser == null) { + if(nodeCollapser == null || branchCollapser == null) throw new NullPointerException("Collapser must not be null"); - } E collapsedNode = nodeCollapser.apply(data); - if (left != null) { + if(left != null) { E collapsedLeftBranch = left.collapse(nodeCollapser, branchCollapser); - if (right != null) { + if(right != null) { E collapsedRightBranch = right.collapse(nodeCollapser, branchCollapser); E collapsedBranches = branchCollapser.apply(collapsedLeftBranch, collapsedRightBranch); @@ -100,7 +96,7 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { return branchCollapser.apply(collapsedNode, collapsedLeftBranch); } - if (right != null) { + if(right != null) { E collapsedRightBranch = right.collapse(nodeCollapser, branchCollapser); return branchCollapser.apply(collapsedNode, collapsedRightBranch); @@ -111,12 +107,10 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { @Override public boolean contains(T element, Comparator comparator) { - if (comparator == null) { - throw new NullPointerException("Comparator must not be null"); - } + if(comparator == null) throw new NullPointerException("Comparator must not be null"); return directedWalk(currentElement -> { - switch (comparator.compare(element, currentElement)) { + switch(comparator.compare(element, currentElement)) { case -1: return LEFT; case 0: @@ -131,12 +125,10 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { @Override public void delete(T element, Comparator comparator) { - if (comparator == null) { - throw new NullPointerException("Comparator must not be null"); - } + if(comparator == null) throw new NullPointerException("Comparator must not be null"); directedWalk(currentElement -> { - switch (comparator.compare(data, element)) { + switch(comparator.compare(data, element)) { case -1: return left == null ? FAILURE : LEFT; case 0: @@ -152,11 +144,9 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { @Override public boolean directedWalk(DirectedWalkFunction treeWalker) { - if (treeWalker == null) { - throw new NullPointerException("Walker must not be null"); - } + if(treeWalker == null) throw new NullPointerException("Walker must not be null"); - switch (treeWalker.walk(data)) { + switch(treeWalker.walk(data)) { case SUCCESS: return true; case LEFT: @@ -172,13 +162,11 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { @Override public boolean forEach(TreeLinearizationMethod linearizationMethod, Predicate traversalPredicate) { - if (linearizationMethod == null) { + if(linearizationMethod == null) throw new NullPointerException("Linearization method must not be null"); - } else if (traversalPredicate == null) { - throw new NullPointerException("Predicate must not be null"); - } + else if(traversalPredicate == null) throw new NullPointerException("Predicate must not be null"); - switch (linearizationMethod) { + switch(linearizationMethod) { case PREORDER: return preorderTraverse(linearizationMethod, traversalPredicate); case INORDER: @@ -192,51 +180,33 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { } private boolean inorderTraverse(TreeLinearizationMethod linearizationMethod, Predicate traversalPredicate) { - if (!traverseLeftBranch(linearizationMethod, traversalPredicate)) { - return false; - } + if(!traverseLeftBranch(linearizationMethod, traversalPredicate)) return false; - if (!traverseElement(traversalPredicate)) { - return false; - } + if(!traverseElement(traversalPredicate)) return false; - if (!traverseRightBranch(linearizationMethod, traversalPredicate)) { - return false; - } + if(!traverseRightBranch(linearizationMethod, traversalPredicate)) return false; return true; } private boolean postorderTraverse(TreeLinearizationMethod linearizationMethod, Predicate traversalPredicate) { - if (!traverseLeftBranch(linearizationMethod, traversalPredicate)) { - return false; - } + if(!traverseLeftBranch(linearizationMethod, traversalPredicate)) return false; - if (!traverseRightBranch(linearizationMethod, traversalPredicate)) { - return false; - } + if(!traverseRightBranch(linearizationMethod, traversalPredicate)) return false; - if (!traverseElement(traversalPredicate)) { - return false; - } + if(!traverseElement(traversalPredicate)) return false; return true; } private boolean preorderTraverse(TreeLinearizationMethod linearizationMethod, Predicate traversalPredicate) { - if (!traverseElement(traversalPredicate)) { - return false; - } + if(!traverseElement(traversalPredicate)) return false; - if (!traverseLeftBranch(linearizationMethod, traversalPredicate)) { - return false; - } + if(!traverseLeftBranch(linearizationMethod, traversalPredicate)) return false; - if (!traverseRightBranch(linearizationMethod, traversalPredicate)) { - return false; - } + if(!traverseRightBranch(linearizationMethod, traversalPredicate)) return false; return true; } @@ -244,7 +214,7 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { private boolean traverseElement(Predicate traversalPredicate) { boolean nodeSuccesfullyTraversed; - if (isDeleted) { + if(isDeleted) { nodeSuccesfullyTraversed = true; } else { nodeSuccesfullyTraversed = traversalPredicate.test(data); @@ -257,7 +227,7 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { Predicate traversalPredicate) { boolean leftSuccesfullyTraversed; - if (left == null) { + if(left == null) { leftSuccesfullyTraversed = true; } else { leftSuccesfullyTraversed = left.forEach(linearizationMethod, traversalPredicate); @@ -270,7 +240,7 @@ public class BinarySearchTreeNode extends BinarySearchTreeLeaf { Predicate traversalPredicate) { boolean rightSuccesfullyTraversed; - if (right == null) { + if(right == null) { rightSuccesfullyTraversed = true; } else { rightSuccesfullyTraversed = right.forEach(linearizationMethod, traversalPredicate); diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/DirectedWalkFunction.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/DirectedWalkFunction.java index e68bef6..e11524a 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/DirectedWalkFunction.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/DirectedWalkFunction.java @@ -2,7 +2,7 @@ package bjc.utils.funcdata.bst; /** * Represents a function for doing a directed walk of a binary tree. - * + * * @author ben * * @param @@ -12,7 +12,7 @@ package bjc.utils.funcdata.bst; public interface DirectedWalkFunction { /** * Represents the results used to direct a walk in a binary tree. - * + * * @author ben * */ @@ -33,14 +33,14 @@ public interface DirectedWalkFunction { RIGHT, /** * Specifies that the function has succesfully completed - * + * */ SUCCESS } /** * Perform a directed walk on a node of a tree. - * + * * @param element * The data stored in the node currently being visited * @return The way the function wants the walk to go next. diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/ITreePart.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/ITreePart.java index c648001..3aa8880 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/ITreePart.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/ITreePart.java @@ -7,7 +7,7 @@ import java.util.function.Predicate; /** * A interface for the fundamental things that want to be part of a tree. - * + * * @author ben * * @param @@ -16,7 +16,7 @@ import java.util.function.Predicate; public interface ITreePart { /** * Add a element below this tree part somewhere. - * + * * @param element * The element to add below this tree part * @param comparator @@ -28,10 +28,10 @@ public interface ITreePart { /** * Collapses this tree part into a single value. Does not change the * underlying tree. - * + * * @param * The type of the final collapsed value - * + * * @param nodeCollapser * The function to use to transform data into mapped * form. @@ -44,7 +44,7 @@ public interface ITreePart { /** * Check if this tre part or below it contains the specified data item - * + * * @param element * The data item to look for. * @param comparator @@ -56,14 +56,14 @@ public interface ITreePart { /** * Get the data associated with this tree part. - * + * * @return The data associated with this tree part. */ public T data(); /** * Remove the given node from this tree part and any of its children. - * + * * @param element * The data item to remove. * @param comparator @@ -73,7 +73,7 @@ public interface ITreePart { /** * Execute a directed walk through the tree. - * + * * @param walker * The function to use to direct the walk through the * tree. @@ -84,7 +84,7 @@ public interface ITreePart { /** * Execute a provided function for each element of tree it succesfully * completes for - * + * * @param linearizationMethod * The way to linearize the tree for executing * @param predicate 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 f7d6280..0c83867 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 @@ -2,7 +2,7 @@ package bjc.utils.funcdata.bst; /** * Represents the ways to linearize a tree for traversal. - * + * * @author ben * */ diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java index fa69f31..d6da637 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Bifunctor.java @@ -4,7 +4,7 @@ import java.util.function.Function; /** * A functor over a pair of heterogenous types - * + * * @author ben * @param * The type stored on the 'left' of the pair @@ -16,7 +16,7 @@ public interface Bifunctor { /** * Lift a pair of functions to a single function that maps over both * parts of a pair - * + * * @param * The old left type of the pair * @param @@ -49,7 +49,7 @@ public interface Bifunctor { /** * Lift a function to operate over the left part of this pair - * + * * @param * The old left type of the pair * @param @@ -66,7 +66,7 @@ public interface Bifunctor { /** * Lift a function to operate over the right part of this pair - * + * * @param * The old left type of the pair * @param @@ -83,14 +83,14 @@ public interface Bifunctor { /** * Get the value contained on the left of this bifunctor - * + * * @return The value on the left side of this bifunctor */ public LeftType getLeft(); /** * Get the value contained on the right of this bifunctor - * + * * @return The value on the right of this bifunctor */ public RightType getRight(); diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Functor.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Functor.java index a5007f1..1c53284 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Functor.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/Functor.java @@ -5,7 +5,7 @@ import java.util.function.Function; /** * Represents a container or context some sort usually, but the precise * definition is that it represents exactly what it is defined as - * + * * @author ben * @param * The value inside the functor @@ -13,11 +13,11 @@ import java.util.function.Function; public interface Functor { /** * Converts a normal function to operate over values in a functor. - * + * * N.B: Even though the type signature implies that you can apply the * resulting function to any type of functor, it is only safe to call it * on instances of the type of functor you called fmap on. - * + * * @param * The argument of the function * @param @@ -32,7 +32,7 @@ public interface Functor { /** * Retrieve the thing inside this functor - * + * * @return The thing inside this functor */ public ContainedType getValue(); diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/package-info.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/package-info.java index 33c80d6..713eb9f 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/package-info.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/theory/package-info.java @@ -1,6 +1,6 @@ /** * Random functional type things that don't belong elsewhere - * + * * @author ben * */ -- cgit v1.2.3