- java.lang.Object
-
- org.scijava.function.Computers
-
public final class Computers extends Object
Container class for computer-style functional interfaces at various arities.A computer has functional method
computewith a number of arguments corresponding to the arity, plus an additional argument for the preallocated output to be populated by the computation.Each computer interface implements a corresponding
Consumer-style interface (seeConsumers) with arity+1; the consumer'sacceptmethod simply delegates tocompute. This pattern allows computer ops to be used directly as consumers as needed.- Author:
- Curtis Rueden, Gabriel Selzer
-
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description static HashMap<Class<?>,Integer>ALL_ARITIESstatic Class<?>[][]ALL_COMPUTERSAll known computer types and their arities.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intarityOf(Class<?> c)static Class<?>computerOfArity(int arity)static Class<?>computerOfArity(int arity, int pos)static booleanisComputer(Class<?> c)
-
-
-
Field Detail
-
ALL_COMPUTERS
public static final Class<?>[][] ALL_COMPUTERS
All known computer types and their arities. The types are indexed, first by the number of pure inputs in their functional method, then by the (1-indexed) index of the preallocated output.Note that this data structure is populated at the bottom of the file, so it does not impede quick browsing of the functional interfaces
-
-
Method Detail
-
isComputer
public static boolean isComputer(Class<?> c)
- Returns:
trueif the given type is a known computer type,falseotherwise.
Note that only the type itself and not its type hierarchy is considered.- Throws:
NullPointerException- Ifcisnull.
-
computerOfArity
public static Class<?> computerOfArity(int arity)
- Parameters:
arity- anintcorresponding to aComputerof that arity.- Returns:
- the
Computerof arityarity. - Throws:
IllegalArgumentException- iff there is no knownComputerof arityarity.
-
computerOfArity
public static Class<?> computerOfArity(int arity, int pos)
- Parameters:
arity- anintcorresponding to aComputerof that arity.pos- anintcorresponding to the position of theComputer's output- Returns:
- the
Computerof arityarity. - Throws:
IllegalArgumentException- iff there is no knownComputerof arityarity.
-
-