Skip to content

Commit d090bba

Browse files
Treiblesschorlectrueden
authored andcommitted
Add ideas as comments
1 parent d95881f commit d090bba

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/main/java/org/scijava/ops/math/Add.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ public Iterable<Double> apply(Iterable<Double> i1, Iterable<Double> i2) {
6464
}
6565

6666
}
67+
68+
// Do we want to have generic types ops?
69+
// Would be cool if someone is looking for an op that expects double and we give him the generic op which works on all numbers.
70+
// Currently, the op calss itself can't have type arguments (possible bug in Types.satisfies) however it works with wildcards
71+
// when there is only an upper bound needed. See below.
72+
73+
// @Plugin(type = MathAddOp.class, priority = Priority.HIGH)
74+
// @Parameter(key = "iter1")
75+
// @Parameter(key = "iter2")
76+
// @Parameter(key = "resultArray", type = ItemIO.OUTPUT)
77+
// public static class MathPointwiseAddIterablesFunction
78+
// implements MathAddOp, BiFunction<Iterable<? extends Number>, Iterable<? extends Number>, Iterable<Double>> {
79+
// @Override
80+
// public Iterable<Double> apply(Iterable<? extends Number> i1, Iterable<? extends Number> i2) {
81+
// Stream<? extends Number> s1 = Streams.stream(i1);
82+
// Stream<? extends Number> s2 = Streams.stream(i2);
83+
// return () -> Streams.zip(s1, s2, (e1, e2) -> e1.doubleValue() + e2.doubleValue()).iterator();
84+
// }
85+
// }
86+
6787
// --------- Computers ---------
6888

6989
@Plugin(type = MathAddOp.class)

src/main/java/org/scijava/ops/util/Functions.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ public static <I, O> Function<I, O> unary(final OpService ops, final Class<? ext
3030
public static <I1, I2, O> BiFunction<I1, I2, O> binary(final OpService ops, final Class<? extends Op> opClass,
3131
final Nil<I1> input1Type, final Nil<I2> input2Type, final Nil<O> outputType,
3232
final Object... secondaryArgs) {
33+
34+
// Parameterize special type corresponding to this method with in/out types. Then we do not have to specify them
35+
// explicitly anymore? Also, outside of this 'Functions' convenience thing, one could just search for the deeply
36+
// typed (having all type variables bound to a specific type) special type. As we are using Types.satisfies, this
37+
// should be type safe. Hence, we could allow to not specify the ins/outs if the special type does not contain
38+
// type variables.
39+
// ParameterizedType parameterizedBiFuncType = Types.parameterize(BiFunction.class,
40+
// new Type[] { input1Type.getType(), input2Type.getType(), outputType.getType() });
41+
3342
return ops.findOp( //
3443
opClass, //
3544
new Nil<BiFunction<I1, I2, O>>() {

0 commit comments

Comments
 (0)