Package zone.lamprey.function
Interface UnaryOperator<T>
- Type Parameters:
T- the type of the operand and result of the operator
- All Superinterfaces:
Function<T,T>,Function<T,T>,UnaryOperator<T>
- All Known Subinterfaces:
DoubleUnaryOperator,IntUnaryOperator,LongUnaryOperator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface UnaryOperator<T> extends Function<T,T>, UnaryOperator<T>
Represents an operation on a single operand that produces a result of the
same type as its operand. This is a specialization of
Function for
the case where the operand and result are of the same type.
This is a functional interface whose
functional method is Function.apply(Object).
- Since:
- 1.8
- See Also:
Function
-
Field Summary
-
Method Summary
Modifier and Type Method Description static <T> UnaryOperator<T>identity()Returns a unary operator that always returns its input argument.default UnaryOperator<T>map(UnaryOperator<T> functor)Lift a function.default Trecurse(T value, int depth)A method that tells a function to call itself with its own result.default Trecurse(T value, Predicate<T> terminalCondition)A method that tells a function to call itself with its own result.default Trecurse(T value, Predicate<T> terminalCondition, int maxDepth)A method that tells a function to call itself with its own result.default UnaryOperator<T>recursive(int depth)A method that creates a function which calls a function with its own result some amount of times.default UnaryOperator<T>recursive(Predicate<T> terminalCondition)A method that creates a function which calls a function with its own result until some condition is met.default UnaryOperator<T>recursive(Predicate<T> terminalCondition, int maxDepth)A method that creates a function which calls a function with its own result some amount of times or until some condition is met.Methods inherited from interface zone.lamprey.function.Function
apply, applyPartial, consume, map, mapToDouble, mapToInt, mapToLong, mapToPredicate
-
Method Details
-
map
Lift a function.- Parameters:
functor- The function to use in lifting.- Returns:
- A function that passes the result of fn through a functor to produce a lifted function.
-
recurse
A method that tells a function to call itself with its own result. This actually imitates recursion using iteration. Don't tell anyone.- Parameters:
value- The initial value to apply to the function.depth- The number of times to recurse. A depth of zero or less will simply return the passed-in value (the function will never be called).- Returns:
- The result of the recursive call.
-
recurse
A method that tells a function to call itself with its own result. This actually imitates recursion using iteration. Don't tell anyone.- Parameters:
value- The initial value to apply to the function.terminalCondition- The condition upon which the "recursion" will terminate.- Returns:
- The result of the recursive call.
-
recurse
A method that tells a function to call itself with its own result. This actually imitates recursion using iteration. Don't tell anyone.- Parameters:
value- The initial value to apply to the function.terminalCondition- The condition upon which the "recursion" will terminate.maxDepth- The maximum number of times to recurse. A depth of zero or less will simply return the passed-in value (the function will never be called).- Returns:
- The result of the recursive call.
-
recursive
A method that creates a function which calls a function with its own result some amount of times.- Parameters:
depth- The number of times to recurse. A depth of zero or less will simply return the value passed toapply(t)(the inner function will never be called).- Returns:
- A function that will call the given function on its own result a number of times as specified by the depth parameter.
-
recursive
A method that creates a function which calls a function with its own result until some condition is met.- Parameters:
terminalCondition- The condition upon which the recursion will terminate.- Returns:
- A function that will call the given function on its own result a number of times as specified by the depth parameter.
-
recursive
A method that creates a function which calls a function with its own result some amount of times or until some condition is met.- Parameters:
terminalCondition- The condition upon which the recursion will terminate.maxDepth- The maximum number of times to recurse. A depth of zero or less will simply return the passed-in value (the function will never be called).- Returns:
- A function that will call the given function on its own result a number of times as specified by the depth parameter.
-
identity
Returns a unary operator that always returns its input argument.- Type Parameters:
T- the type of the input and output of the operator- Returns:
- a unary operator that always returns its input argument
-