45. 構文木を触ってみる(1)
public class Test024 {
public int test024_1(List<Integer> lst) {
return lst.stream().filter(x -> x % 2 == 1).mapToInt(i -> i).sum();
}
}
public class Test024 {
public Test024() { super(); }
public int test024_1(List lst) {
return lst.stream()
.filter(java.lang.invoke.LambdaMetafactory.metafactory())
.mapToInt(java.lang.invoke.LambdaMetafactory.metafactory())
.sum();
}
/*synthetic*/ private static int lambda$test024_1$1(Integer i) {
return i.intValue();
}
/*synthetic*/ private static boolean lambda$test024_1$0(Integer x) {
return x.intValue() % 2 == 1;
}
}
46. 構文木を触ってみる(2)
public class Test025 {
public int test025_1(List<Integer> lst){
return lst.stream().mapToInt(i -> i).sum();
}
public int test025_2(List<Integer> lst) {
return lst.stream().filter(x -> x % 2 == 1).mapToInt(i -> i).sum();
}
}
47. 構文木を触ってみる(2)
public class Test025 {
public Test025() { super(); }
public int test025_1(List lst) {
return lst.stream()
.mapToInt(java.lang.invoke.LambdaMetafactory.metafactory())
.sum();
}
public int test025_2(List lst) {
return lst.stream()
.filter(java.lang.invoke.LambdaMetafactory.metafactory())
.mapToInt(java.lang.invoke.LambdaMetafactory.metafactory())
.sum();
}
/*synthetic*/ private static boolean lambda$test025_2$1(Integer x) {
return x.intValue() % 2 == 1;
}
/*synthetic*/ private static int lambda$test025_1$0(Integer i) {
return i.intValue();
}
}
50. Stream APIでハードウェアをたたく
public class StreamTest {
public int doWithSoftware(List<Integer> lst) {
return lst.stream().filter(x -> x % 2 == 1).mapToInt(i -> i).sum();
}
public int doWithHardware(List<Integer> lst) {
return new lst.stream().reduce(new EvenFilteredSum());
}
}
public class EvenFilteredSum extends RTLModule implements IntBinaryOperator {
static { System.loadLibrary(“EvenFilteredSumWrapper”); }
private native void runOnHardware(int[] buf);
int[] buffer = int[BUFSIZE];
public int applyAsInt(int left, int right){
…
runOnHardware(buffer);
}
}