/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static IntStream stream(OptionalInt optional) { return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty(); }
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; }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static IntStream stream(OptionalInt optional) { return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty(); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static IntStream stream(OptionalInt optional) { return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty(); }
public PageChannelSelector(int... channels) { checkArgument(IntStream.of(channels).allMatch(channel -> channel >= 0), "channels must be positive"); this.channels = requireNonNull(channels, "channels is null").clone(); }
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); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static IntStream stream(OptionalInt optional) { return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty(); }
private List<Integer> getValidAddresses() { return IntStream.of(manipulator.getAddresses()).boxed().filter(this::canConstantizeAddress) .collect(Collectors.toList()); }
List<Integer> getValidAddresses(ExecutionGraphManipulator manipulator) { return IntStream.of(manipulator.getAddresses()).boxed().filter(manipulator::wasAddressReached) .collect(Collectors.toList()); }
private IntStream propertyKeyIds( IndexPopulation population ) { return IntStream.of( population.schema().getPropertyIds() ); }
public void testMapWithIndex_intStream_closeIsPropagated_sized() { testMapWithIndex_intStream_closeIsPropagated(IntStream.of(1, 2, 3)); }
@Override public int length() { return IntStream.concat( IntStream.of(baseGraph.getAllEdges().length() - 1), extraEdges.stream().mapToInt(VirtualEdgeIteratorState::getEdge)) .max().getAsInt()+1; }
public static IntPair minimize_unsorted(int[] numbers) { int[] sorted = IntStream.of(numbers).sorted().toArray(); return minimize_sorted(sorted); }
int getMaxValue(final List<int[]> vals) { return vals .stream() .mapToInt(array -> IntStream.of(array).max().orElse(0)) .max() .orElseThrow(NoSuchElementException::new); }
PartiallyFailingIndexer(IndexType indexType, int... successfulReturns) { this.indexType = indexType; this.successfulReturns = IntStream.of(successfulReturns).iterator(); }
public void testMapWithIndex_intStream() { SpliteratorTester.of( () -> Streams.mapWithIndex(IntStream.of(0, 1, 2), (x, i) -> x + ":" + i).spliterator()) .expect("0:0", "1:1", "2:2"); }
public void testCopyOf_stream() { assertThat(ImmutableIntArray.copyOf(IntStream.empty())).isSameAs(ImmutableIntArray.of()); assertThat(ImmutableIntArray.copyOf(IntStream.of(0, 1, 3)).asList()) .containsExactly(0, 1, 3) .inOrder(); }