本文整理汇总了Java中java.util.IntSummaryStatistics.getMax方法的典型用法代码示例。如果您正苦于以下问题:Java IntSummaryStatistics.getMax方法的具体用法?Java IntSummaryStatistics.getMax怎么用?Java IntSummaryStatistics.getMax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.IntSummaryStatistics
的用法示例。
在下文中一共展示了IntSummaryStatistics.getMax方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsInt
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
@Override
public int getAsInt() {
BinaryOperator<Dimension> accumulator = new BinaryOperator<Dimension>() {
@Override
public Dimension apply(Dimension t, Dimension u) {
int w = Math.max(t.width, u.width);
int h = Math.max(t.height, u.height);
return new Dimension(w, h);
}
};
Dimension extent = plantingBlockModel.getPlantingBlocks().stream()
.map(pb -> new Dimension( pb.getX() + pb.getColumnCount() - 1, pb.getY() + pb.getRowCount() - 1 ))
.reduce(new Dimension(0,0), accumulator);
IntSummaryStatistics stats = plantingBlockModel.getPlantingBlocks().stream()
.collect(Collectors.summarizingInt(pb -> pb.getColumnCount() * pb.getRowCount()));
int maxSize = stats.getMax();
int maxExtent = extent.width * extent.height;
return Math.max(maxSize, maxExtent);
}
示例2: printRange
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
private void printRange(String string, IntSummaryStatistics perf) {
int max = perf.getMax();
int min = perf.getMin();
if (min == max) {
out.printf("%12s: %3d%n", string, max);
} else {
out.printf("%12s: %3d - %3d%n", string, min, max);
}
}
示例3: isAllowed
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
@Override
public boolean isAllowed(Player player) {
if (Arrays.stream(properties).map(Property::getGroup).distinct().count() != 1) {
// Can only buy on one group at a time
return false;
}
if (properties[0].getGroup().getHouseCost() <= 0) {
// Not possible to buy on all groups
return false;
}
if (!properties[0].getGroup().getProperties().stream().allMatch(p -> p.isOwnedBy(player))) {
// Can only buy if you own the whole group
return false;
}
PropertyGroup group = properties[0].getGroup();
int[] resultingHouseCount = group.getProperties().stream().mapToInt(Property::getHouseCount).toArray();
for (int i = 0; i < amount; i++) {
int index = i % properties.length;
Property property = properties[index];
int groupIndex = group.getProperties().indexOf(property);
resultingHouseCount[groupIndex]++;
}
IntSummaryStatistics stats = Arrays.stream(resultingHouseCount).summaryStatistics();
boolean balanced = stats.getMax() - stats.getMin() <= 1;
return balanced && player.getGame().isEmptyStack() && player.getGame().getCurrentPlayer() == player && player.getMoney() >= getCost();
}
示例4: aggregate
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public RequestAggregationValues aggregate(RequestCollector requests) {
IntSummaryStatistics stats = requests.getReqTimestamps().stream().collect(Collectors.groupingBy(timestamp -> DateUtils.round(new Date(timestamp), timestampAggregation), Collectors.counting()))
.values().stream().mapToInt(p -> toInt(p)).summaryStatistics();
return new RequestAggregationValuesImpl(stats.getMin(), stats.getMax(), stats.getAverage(), stats.getSum(), stats.getCount());
}
示例5: report
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
@Override
public void report() {
final IntStream yearStream = yearToMovieCount.keySet().stream().mapToInt(Integer::intValue);
final IntSummaryStatistics summaryStatistics = yearStream.summaryStatistics();
final List<Integer> yearWithoutMovies = new ArrayList<>();
for (int year = summaryStatistics.getMin(); year <= summaryStatistics.getMax(); year++)
if (!yearToMovieCount.containsKey(year))
yearWithoutMovies.add(year);
System.out.println(String.format("Years without movies: %s.", yearWithoutMovies));
}
示例6: of
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
/**
* Return a new value object of the statistical summary, currently
* represented by the {@code statistics} object.
*
* @param statistics the creating (mutable) statistics class
* @return the statistical moments
*/
public static IntSummary of(final IntSummaryStatistics statistics) {
return new IntSummary(
statistics.getCount(),
statistics.getMin(),
statistics.getMax(),
statistics.getSum(),
statistics.getAverage()
);
}
示例7: computeNQ1PlusConcurringDuplexes
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
@SuppressWarnings("ReferenceEquality")
public int computeNQ1PlusConcurringDuplexes(Histogram concurringDuplexDistances, Parameters param) {
MutableIntList alignmentStarts = IntLists.mutable.empty();
final Duplex bestSupporting = getDuplexes().max(getDuplexQualityComparator());
//Exclude duplexes whose reads all have an unmapped mate from the count
//of Q1-Q2 duplexes that agree with the mutation; otherwise failed reads
//may cause an overestimate of that number
//Also exclude duplexes with clipping greater than maxConcurringDuplexClipping
final int nConcurringDuplexes = getDuplexes().count(d -> {
//noinspection ObjectEquality
if (d == bestSupporting) {
return true;
}
boolean good =
d.allRecords.size() >= param.minConcurringDuplexReads * 2 /* double to account for mates */ &&
d.localAndGlobalQuality.getValueIgnoring(assaysToIgnoreIncludingDuplexNStrands()).
atLeast(Quality.GOOD) &&
d.allRecords.anySatisfy(r -> !r.record.getMateUnmappedFlag()) &&
d.allRecords.anySatisfy(r -> concurringDuplexReadClippingOK(r, param)) &&
d.computeMappingQuality() >= param.minMappingQualityQ1;
if (good) {
final int distance = d.distanceTo(bestSupporting);
alignmentStarts.add(distance);
if (concurringDuplexDistances != null) {
concurringDuplexDistances.insert(distance);
}
}
return good;
});
if (!alignmentStarts.isEmpty()) {
IntSummaryStatistics stats = alignmentStarts.summaryStatistics();
smallestConcurringDuplexDistance = stats.getMin();
largestConcurringDuplexDistance = stats.getMax();
}
nQ1PlusConcurringDuplexes = nConcurringDuplexes;
return nConcurringDuplexes;
}
示例8: aggregate
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public RequestAggregationValues aggregate(RequestCollector requests) {
double expectedCount = getExpectedNumberOfMeasurementValueGroups();
/*
* Group by aggregation interval and create summary statistics with min, avg, max and count
*/
Collection<Long> groupedByAggregationInterval = requests.getReqTimestamps().stream()
.collect(Collectors.groupingBy(timestamp -> DateUtils.round(new Date(timestamp), timestampAggregation), Collectors.counting())).values();
int calculatedCount = groupedByAggregationInterval.size();
try {
if (calculatedCount != 0) {
// use integer summaryStatistics to get min, avg, max
IntSummaryStatistics stats = groupedByAggregationInterval.stream().mapToInt(p -> toInt(p)).summaryStatistics();
// no time range selected, just return int summary
if (expectedCount == 0) {
return new RequestAggregationValuesImpl(stats.getMin(), stats.getMax(), stats.getAverage(), stats.getSum(), stats.getCount());
}
else {
// if calculated count != expected count --> adjust minimum, average and count value
if (Double.compare(calculatedCount, expectedCount) != 0) {
double newAverage = (double) (stats.getSum() / expectedCount);
return new RequestAggregationValuesImpl(0, stats.getMax(), newAverage, stats.getSum(), (int) expectedCount);
}
else {
return new RequestAggregationValuesImpl(stats.getMin(), stats.getMax(), stats.getAverage(), stats.getSum(), (int) expectedCount);
}
}
}
else {
return new RequestAggregationValuesImpl(0, 0, 0, 0, 0);
}
}
catch (ArithmeticException e) {
System.out.println(e.getMessage());
return new RequestAggregationValuesImpl(0, 0, 0, 0, 0);
}
}
示例9: SummaryStatistics
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
public SummaryStatistics(IntSummaryStatistics statistics) {
this(statistics.getAverage(), statistics.getMax(),
statistics.getMin(), statistics.getCount(),
statistics.getSum());
}