use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.
the class InternalArrayIterate method summarizeDouble.
/**
* @since 8.0
*/
public static <T> DoubleSummaryStatistics summarizeDouble(T[] items, int size, DoubleFunction<? super T> function) {
DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
for (int i = 0; i < size; i++) {
T item = items[i];
stats.accept(function.doubleValueOf(item));
}
return stats;
}
use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.
the class AbstractRichIterableTestCase method summarizeDouble.
@Test
public void summarizeDouble() {
RichIterable<Integer> objects = this.newWith(1, 2, 3);
DoubleSummaryStatistics expected = objects.summarizeDouble(Integer::doubleValue);
Assert.assertEquals(6.0d, expected.getSum(), 0.0);
Assert.assertEquals(3, expected.getCount());
}
use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.
the class RichIterable method summarizeFloat.
/**
* Returns the result of summarizing the value returned from applying the FloatFunction to
* each element of the iterable.
* <p>
* <pre>
* DoubleSummaryStatistics stats =
* Lists.mutable.with(1, 2, 3).summarizeFloat(Integer::floatValue);
* </pre>
*
* @since 8.0
*/
default DoubleSummaryStatistics summarizeFloat(FloatFunction<? super T> function) {
DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
this.each(each -> stats.accept(function.floatValueOf(each)));
return stats;
}
use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.
the class Bag method summarizeFloat.
/**
* @since 8.0
*/
@Override
default DoubleSummaryStatistics summarizeFloat(FloatFunction<? super T> function) {
DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
this.forEachWithOccurrences((each, occurrences) -> {
float result = function.floatValueOf(each);
for (int i = 0; i < occurrences; i++) {
stats.accept(result);
}
});
return stats;
}
use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.
the class Bag method summarizeDouble.
/**
* @since 8.0
*/
@Override
default DoubleSummaryStatistics summarizeDouble(DoubleFunction<? super T> function) {
DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
this.forEachWithOccurrences((each, occurrences) -> {
double result = function.doubleValueOf(each);
for (int i = 0; i < occurrences; i++) {
stats.accept(result);
}
});
return stats;
}
Aggregations