Added direct core-vault chaining
@@ -147,7 +147,7 @@ public class Array<T> implements Iterable<T>{
return new Array<>(this);
}
- public float sum(FloatFunction<T> summer){
+ public float sumf(FloatFunction<T> summer){
float sum = 0;
for(int i = 0; i < size; i++){
sum += summer.get(items[i]);
@@ -155,6 +155,14 @@ public class Array<T> implements Iterable<T>{
return sum;
}
+ public int sum(IntFunction<T> summer){
+ int sum = 0;
+ for(int i = 0; i < size; i++){
+ sum += summer.get(items[i]);
+ }
+ return sum;
+ }
+
public <E extends T> void each(Predicate<? super T> pred, Consumer<E> consumer){
for(int i = 0; i < size; i++){
if(pred.test(items[i])) consumer.accept((E)items[i]);
