make list function descriptions follow a pattern

This commit is contained in:
Jonathan Shook 2020-07-07 11:40:26 -05:00
parent 0de0cc7d69
commit 6a22d411a0
6 changed files with 53 additions and 44 deletions

View File

@ -13,10 +13,13 @@ import java.util.function.LongFunction;
import java.util.function.LongUnaryOperator;
/**
* Create a {@code List} from a long input
* based on list of functions without any size boundaries,
* each function in the list functions populate the list with
* object value.
* Create a List from a long input based on a set of provided functions.
*
* As a 'Pair-wise' function, the size of the resulting collection is determined directly by the
* number of provided element functions.
*
* As neither a 'Stepped' nor a 'Hashed' function, the input value used by each element function is the same
* as that provided to the outer function.
*/
@Categories({Category.collections})
@ThreadSafeMapper
@ -27,7 +30,7 @@ public class ListFunctions implements LongFunction<java.util.List<Object>> {
@Example({
"ListFunctions(NumberNameToString(),NumberNameToString(),NumberNameToString())",
"Create a list of object values of each function output. ListFunctions output ['one','one','one']"
"Create a list of object values of each function output. Produces values like ['one','one','one']"
})
public ListFunctions(LongFunction<? extends Object>... funcs) {
this.valueFuncs = Arrays.asList(funcs);
@ -43,9 +46,9 @@ public class ListFunctions implements LongFunction<java.util.List<Object>> {
this.size = building.size();
}
public ListFunctions(Function<Long,Object>... funcs) {
public ListFunctions(Function<Long, Object>... funcs) {
List<LongFunction<?>> building = new ArrayList<>(funcs.length);
for (Function<Long,Object> func : funcs) {
for (Function<Long, Object> func : funcs) {
building.add(func::apply);
}
this.valueFuncs = building;

View File

@ -15,10 +15,12 @@ import java.util.function.LongToIntFunction;
import java.util.function.LongUnaryOperator;
/**
* Create a {@code List} from a long input
* based on pseudo-randomly hash list of functions without any size boundaries,
* each function in the list functions populate the hash list with
* object value.
* Create a List from a long input based on a set of provided functions.
*
* As a 'Pair-wise' function, the size of the resulting collection is determined directly by the
* number of provided element functions.
*
* As a 'Hashed' function, the input value is hashed again before being used by each element function.
*/
@Categories({Category.collections})
@ThreadSafeMapper
@ -29,7 +31,7 @@ public class ListHashed implements LongFunction<List<Object>> {
private final Hash hasher = new Hash();
@Example({
"ListHashed(long->ToString(), long->WeightedStrings('text:1'))",
"ListHashed(ToString(), WeightedStrings('text:1'))",
"Create a hash list of object values of each function output. ListHashed output ['2945182322382062539','text']"
})
public ListHashed(LongFunction<? extends Object>... funcs) {
@ -46,9 +48,9 @@ public class ListHashed implements LongFunction<List<Object>> {
this.size = building.size();
}
public ListHashed(Function<Long,Object>... funcs) {
public ListHashed(Function<Long, Object>... funcs) {
List<LongFunction<?>> building = new ArrayList<>(funcs.length);
for (Function<Long,Object> func : funcs) {
for (Function<Long, Object> func : funcs) {
building.add(func::apply);
}
this.valueFuncs = building;

View File

@ -14,10 +14,14 @@ import java.util.function.LongToIntFunction;
import java.util.function.LongUnaryOperator;
/**
* Create a {@code List} from a long input
* based on at least two functions, the first function to
* determine the list functions size, and the remaining functions onwards to populate
* the list with object values till the end of the list size.
* Create a List from a long input based on a set of provided functions.
*
* As a 'Sized' function, the first argument is a function which determines the size of the resulting list.
* Additional functions provided are used to generate the elements to add to the collection. If the size
* is larger than the number of provided functions, the last provided function is used repeatedly as needed.
*
* As neither a 'Stepped' nor a 'Hashed' function, the input value used by each element function is the same
* as that provided to the outer function.
*/
@Categories({Category.collections})
@ThreadSafeMapper
@ -46,9 +50,9 @@ public class ListSized implements LongFunction<List<Object>> {
this.valueFuncs = building;
}
public ListSized(LongToIntFunction sizeFunc, Function<Long,Object>... funcs) {
public ListSized(LongToIntFunction sizeFunc, Function<Long, Object>... funcs) {
List<LongFunction<?>> building = new ArrayList<>(funcs.length);
for (Function<Long,Object> func : funcs) {
for (Function<Long, Object> func : funcs) {
building.add(func::apply);
}
this.sizeFunc = sizeFunc;

View File

@ -15,10 +15,13 @@ import java.util.function.LongToIntFunction;
import java.util.function.LongUnaryOperator;
/**
* Create a {@code List} from a long input
* based on at least two functions, the first function to
* determine the list functions size, and the remaining functions onwards to populate
* the list with object values till the end of the list size.
* Create a List from a long input based on a set of provided functions.
*
* As a 'Sized' function, the first argument is a function which determines the size of the resulting list.
* Additional functions provided are used to generate the elements to add to the collection. If the size
* is larger than the number of provided functions, the last provided function is used repeatedly as needed.
*
* As a 'Hashed' function, the input value is hashed again before being used by each element function.
*/
@Categories({Category.collections})
@ThreadSafeMapper

View File

@ -15,14 +15,13 @@ import java.util.function.LongToIntFunction;
import java.util.function.LongUnaryOperator;
/**
* Create a {@code List} from a long input
* based on two functions, the first to
* determine the list size, and the second to populate the list with
* object values. The input fed to the second function is incremented
* between elements.
* Create a List from a long input based on a set of provided functions.
*
* To directly create Lists of Strings from the String version of the same
* mapping functions, simply use {@link StringList} instead.
* As a 'Sized' function, the first argument is a function which determines the size of the resulting list.
* Additional functions provided are used to generate the elements to add to the collection. If the size
* is larger than the number of provided functions, the last provided function is used repeatedly as needed.
*
* As a 'Stepped' function, the input value is incremented before being used by each element function.
*/
@Categories({Category.collections})
@ThreadSafeMapper

View File

@ -14,14 +14,12 @@ import java.util.function.LongToIntFunction;
import java.util.function.LongUnaryOperator;
/**
* Create a {@code List} from a long input
* based on two functions, the first to
* determine the list size, and the second to populate the list with
* object values. The input fed to the second function is incremented
* between elements.
* Create a List from a long input based on a set of provided functions.
*
* To directly create Lists of Strings from the String version of the same
* mapping functions, simply use {@link StringList} instead.
* As a 'Pair-wise' function, the size of the resulting collection is determined directly by the
* number of provided element functions.
*
* As a 'Stepped' function, the input value is incremented before being used by each element function.
*/
@Categories({Category.collections})
@ThreadSafeMapper