public OptionalInt totalPoints(List<List<Number>> listData) { return listData.stream(). mapToInt(List::size). max(); }
public BucketPartitionFunction(BucketFunction bucketFunction, int[] bucketToPartition) { this.bucketFunction = requireNonNull(bucketFunction, "bucketFunction is null"); this.bucketToPartition = requireNonNull(bucketToPartition, "bucketToPartition is null").clone(); partitionCount = IntStream.of(bucketToPartition).max().getAsInt() + 1; }
private int computeTotalMainWidth() { final List<AttributedString> mainLines = getMainLines(); final List<AttributedString> mainHeaderLines = getMainHeaderLines(); final int max1 = mainLines.stream().mapToInt(AttributedString::length).max().orElse(0); final int max2 = mainHeaderLines.stream().mapToInt(AttributedString::length).max().orElse(0); return Math.max(max1, max2); }
private int getMultiLineStringLength(final String multiLineString) { final String[] split = multiLineString.split("\n"); return Arrays.stream(split) .mapToInt(String::length) .max() .orElse(0); }
public static WriteChecksumBuilder createWriteChecksumBuilder(Map<Integer, Type> readColumns) { requireNonNull(readColumns, "readColumns is null"); checkArgument(!readColumns.isEmpty(), "readColumns is empty"); int columnCount = readColumns.keySet().stream() .mapToInt(Integer::intValue) .max().getAsInt() + 1; checkArgument(readColumns.size() == columnCount, "checksum requires all columns to be read"); ImmutableList.Builder<Type> types = ImmutableList.builder(); for (int column = 0; column < columnCount; column++) { Type type = readColumns.get(column); checkArgument(type != null, "checksum requires all columns to be read"); types.add(type); } return new WriteChecksumBuilder(types.build()); }
public StatisticsValidation createWriteStatisticsBuilder(Map<Integer, Type> readColumns) { requireNonNull(readColumns, "readColumns is null"); checkArgument(!readColumns.isEmpty(), "readColumns is empty"); int columnCount = readColumns.keySet().stream() .mapToInt(Integer::intValue) .max().getAsInt() + 1; checkArgument(readColumns.size() == columnCount, "statistics validation requires all columns to be read"); ImmutableList.Builder<Type> types = ImmutableList.builder(); for (int column = 0; column < columnCount; column++) { Type type = readColumns.get(column); checkArgument(type != null, "statistics validation requires all columns to be read"); types.add(type); } return new StatisticsValidation(types.build()); }
public static WriteChecksumBuilder createWriteChecksumBuilder(Map<Integer, Type> readColumns) { requireNonNull(readColumns, "readColumns is null"); checkArgument(!readColumns.isEmpty(), "readColumns is empty"); int columnCount = readColumns.keySet().stream() .mapToInt(Integer::intValue) .max().getAsInt() + 1; checkArgument(readColumns.size() == columnCount, "checksum requires all columns to be read"); ImmutableList.Builder<Type> types = ImmutableList.builder(); for (int column = 0; column < columnCount; column++) { Type type = readColumns.get(column); checkArgument(type != null, "checksum requires all columns to be read"); types.add(type); } return new WriteChecksumBuilder(types.build()); }
private int extractMaxIndex(String key, String suffixPattern) { // extract index and property keys final String escapedKey = Pattern.quote(key); final Pattern pattern = Pattern.compile(escapedKey + "\\.(\\d+)" + suffixPattern); final IntStream indexes = properties.keySet().stream() .flatMapToInt(k -> { final Matcher matcher = pattern.matcher(k); if (matcher.find()) { return IntStream.of(Integer.valueOf(matcher.group(1))); } return IntStream.empty(); }); // determine max index return indexes.max().orElse(-1); }
private int getColumnLength(final List<String> columnHeaders, final List<List<String>> rowValues, final int i) { return Math.max( columnHeaders.get(i).length(), rowValues .stream() .mapToInt(r -> getMultiLineStringLength(r.get(i))) .max() .orElse(0)); }
@Benchmark public int serial_lazy_intstream_jdk() { return this.integersJDK.stream().mapToInt(Integer::intValue).max().getAsInt(); }
public static IntPair maximize_unsorted(int[] numbers) { OptionalInt min = IntStream.of(numbers).min(); OptionalInt max = IntStream.of(numbers).max(); return new IntPair(min.getAsInt(), max.getAsInt()); }
private static List<Type> toTypes(Map<Symbol, Integer> layout, LocalExecutionPlanContext context) { // verify layout covers all values int channelCount = layout.values().stream().mapToInt(Integer::intValue).max().orElse(-1) + 1; checkArgument( layout.size() == channelCount && ImmutableSet.copyOf(layout.values()).containsAll(ContiguousSet.create(closedOpen(0, channelCount), integers())), "Layout does not have a symbol for every output channel: %s", layout); Map<Integer, Symbol> channelLayout = ImmutableBiMap.copyOf(layout).inverse(); return range(0, channelCount) .mapToObj(channelLayout::get) .map(context.getTypes()::get) .collect(toImmutableList()); }
@Override public int length() { return IntStream.concat( IntStream.of(baseGraph.getAllEdges().length() - 1), extraEdges.stream().mapToInt(VirtualEdgeIteratorState::getEdge)) .max().getAsInt()+1; }
private static VarcharType varcharType(List<String> values) { if (values.stream().anyMatch(Objects::isNull)) { return VARCHAR; } return createVarcharType(values.stream().mapToInt(String::length).max().getAsInt()); }
private int maxValue() { return Arrays.stream( elements ) .mapToInt( value -> NumberUtils.toInt( value, 0 )).max().getAsInt(); } }
@Override public int getNodes() { return IntStream.concat( IntStream.of(baseGraph.getNodes()-1), extraEdges.stream().flatMapToInt(edge -> IntStream.of(edge.getBaseNode(), edge.getAdjNode()))) .max().getAsInt()+1; }
@Override public int getNodes() { return IntStream.concat( IntStream.of(graphHopperStorage.getNodes()-1), additionalEdges.stream().flatMapToInt(edge -> IntStream.of(edge.getBaseNode(), edge.getAdjNode()))) .max().getAsInt()+1; }
private int insertPublicProjectsWithBranches(OrganizationDto org, MetricDto ncloc, int minimumNcloc) { // private project ComponentDto project1 = db.components().insertPublicProject(org); return Math.max( // Create the ncloc on main branch insertLiveMeasures(project1, ncloc, minimumNcloc), // Create 5 branches and set the ncloc on them IntStream.range(1, 5) .map(i -> insertLiveMeasures(db.components().insertProjectBranch(project1), ncloc, minimumNcloc)) .max().orElse(0) ); }
private int insertPrivateProjectsWithBranches(OrganizationDto org, MetricDto ncloc) { // private project ComponentDto project1 = db.components().insertMainBranch(org); return Math.max( // Create the ncloc on main branch insertLiveMeasures(project1, ncloc, 0), // Create 5 branches and set the ncloc on them IntStream.range(1, 5) .map(i -> insertLiveMeasures(db.components().insertProjectBranch(project1), ncloc, 0)) .max().orElse(0) ); }