Java Code Examples for java.util.stream.IntStream#of()
The following examples show how to use
java.util.stream.IntStream#of() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: rtc2jira File: Settings.java License: GNU General Public License v2.0 | 6 votes |
public Collection<Integer> getRtcWorkItemRange() { String rangesString = props.getProperty(RTC_WORKITEM_ID_RANGE); String[] ranges = rangesString.split(","); IntStream intStream = IntStream.of(); for (String range : ranges) { String[] splitted = range.split("\\.\\."); int from = Integer.parseInt(splitted[0].trim()); if (splitted.length == 1) { intStream = IntStream.concat(intStream, IntStream.rangeClosed(from, from)); } else { int to = Integer.parseInt(splitted[1].trim()); intStream = IntStream.concat(intStream, IntStream.rangeClosed(from, to)); } } return intStream.boxed().collect(Collectors.toList()); }
Example 2
Source Project: Java-Coding-Problems File: Convertors.java License: MIT License | 5 votes |
public static IntStream toStream5(int[] arr) { if (arr == null) { throw new IllegalArgumentException("Inputs cannot be null"); } return IntStream.of(arr); }
Example 3
Source Project: groovy File: PluginDefaultGroovyMethods.java License: Apache License 2.0 | 5 votes |
/** * If a value is present in the {@link OptionalInt}, returns an {@link IntStream} * with the value as its source or else an empty stream. * * @since 3.0.0 */ public static IntStream stream(final OptionalInt self) { if (!self.isPresent()) { return IntStream.empty(); } return IntStream.of(self.getAsInt()); }
Example 4
Source Project: TweetwallFX File: Tweet.java License: MIT License | 5 votes |
public String get() { if (entriesToRemove.isEmpty()) { return tweet.getText(); } IntStream filteredIndexes = IntStream.empty(); for (TweetEntry tweetEntry : entriesToRemove) { final IntStream nextFilter; if (tweetEntry.getStart() == tweetEntry.getEnd()) { nextFilter = IntStream.of(tweetEntry.getStart()); } else { nextFilter = IntStream.range(tweetEntry.getStart(), tweetEntry.getEnd()); } filteredIndexes = IntStream.concat(filteredIndexes, nextFilter); } final Set<Integer> indexesToFilterOut = filteredIndexes.boxed().collect(toCollection(TreeSet::new)); final int[] chars = tweet.getText().chars().toArray(); final int[] filteredChars = IntStream.range(0, chars.length) .filter(i -> !indexesToFilterOut.contains(i)) .map(i -> chars[i]) .toArray(); return new String(filteredChars, 0, filteredChars.length) .replaceAll(" *", " ") .trim(); }
Example 5
Source Project: levelup-java-examples File: ConcatenateStream.java License: Apache License 2.0 | 5 votes |
@Test public void join_intstream() { IntStream intStream1 = IntStream.of(1, 2); IntStream intStream2 = IntStream.of(3, 4); IntStream.concat(intStream1, intStream2).forEach( e -> System.out.println(e)); }
Example 6
Source Project: levelup-java-examples File: SumUniqueValsTwoIntStreams.java License: Apache License 2.0 | 4 votes |
@Test public void sum_unique_values_intstream() { IntStream stream1 = IntStream.of(1, 2, 3); IntStream stream2 = IntStream.of(1, 2, 3); int val = IntStream.concat(stream1, stream2).distinct().sum(); assertEquals(6, val); // or IntStream stream3 = IntStream.of(1, 2, 3); IntStream stream4 = IntStream.of(1, 2, 3); OptionalInt sum2 = IntStream.concat(stream3, stream4).distinct() .reduce((a, b) -> a + b); assertEquals(6, sum2.getAsInt()); }
Example 7
Source Project: carpet-extra File: HopperMinecartEntity_transferItemsOutFeatureMixin.java License: GNU Lesser General Public License v3.0 | 4 votes |
private static IntStream getAvailableSlots(Inventory inventory_1, Direction direction_1) { return inventory_1 instanceof SidedInventory ? IntStream.of(((SidedInventory)inventory_1).getInvAvailableSlots(direction_1)) : IntStream.range(0, inventory_1.getInvSize()); }
Example 8
Source Project: testing-video File: CalibrateSaturation1080pHLG10_CalMAN.java License: GNU General Public License v3.0 | 4 votes |
@Override protected IntStream stimulus() { return IntStream.of(25, 50, 75); }
Example 9
Source Project: ApprovalTests.Java File: NumberUtils.java License: Apache License 2.0 | 4 votes |
public static IntStream toIntStream(int[] numbers) { return IntStream.of(numbers); }
Example 10
Source Project: testing-video File: CalibrateSaturation2160pHLG10_CalMAN.java License: GNU General Public License v3.0 | 4 votes |
@Override protected IntStream stimulus() { return IntStream.of(25, 50, 75); }
Example 11
Source Project: testing-video File: CalibrateSaturationBase_CalMAN.java License: GNU General Public License v3.0 | 4 votes |
protected IntStream stimulus() { return IntStream.of(75, 100); }
Example 12
Source Project: RoaringBitmap File: RandomisedTestData.java License: Apache License 2.0 | 4 votes |
private static IntStream sparseRegion() { return IntStream.of(createSorted16BitInts(ThreadLocalRandom.current().nextInt(1, 4096))); }
Example 13
Source Project: Mastering-Software-Testing-with-JUnit-5 File: MethodSourcePrimitiveTypesParameterizedTest.java License: MIT License | 4 votes |
static IntStream intProvider() { return IntStream.of(0, 1); }
Example 14
Source Project: RankSys File: IteratorsAbstractFastPreferenceDataTest.java License: Mozilla Public License 2.0 | 4 votes |
@Override public IntIterator getIidxUidxs(int iidx) { return new StreamIntIterator(IntStream.of(18, 20, 100, 101, 102)); }
Example 15
Source Project: RoaringBitmap File: RandomisedTestData.java License: Apache License 2.0 | 4 votes |
private static IntStream denseRegion() { return IntStream.of(createSorted16BitInts(ThreadLocalRandom.current().nextInt(4096, 1 << 16))); }
Example 16
Source Project: blog-tutorials File: StreamsUpdate.java License: MIT License | 3 votes |
public static void main(String[] args) { final IntStream intStream1 = IntStream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); System.out.println( intStream1.takeWhile(n -> n <= 5).mapToObj(Integer::toString).collect(Collectors.joining(", "))); final IntStream intStream2 = IntStream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); System.out.println(intStream2.dropWhile(n -> n < 5).sum()); final List<String> names = List.of("Tom", "Paul", "Mike", "Duke", "", "Michelle", "Anna"); names.stream().takeWhile(s -> !s.isEmpty()).forEach(System.out::println); }
Example 17
Source Project: openjdk-jdk9 File: OptionalInt.java License: GNU General Public License v2.0 | 3 votes |
/** * If a value is present, returns a sequential {@link IntStream} containing * only that value, otherwise returns an empty {@code IntStream}. * * @apiNote * This method can be used to transform a {@code Stream} of optional * integers to an {@code IntStream} of present integers: * <pre>{@code * Stream<OptionalInt> os = .. * IntStream s = os.flatMapToInt(OptionalInt::stream) * }</pre> * * @return the optional value as an {@code IntStream} * @since 9 */ public IntStream stream() { if (isPresent) { return IntStream.of(value); } else { return IntStream.empty(); } }
Example 18
Source Project: Strata File: IntArray.java License: Apache License 2.0 | 2 votes |
/** * Returns a stream over the array values. * * @return a stream over the values in the array */ public IntStream stream() { return IntStream.of(array); }
Example 19
Source Project: FXyzLib File: Face3.java License: GNU General Public License v3.0 | votes |
public IntStream getFace(int t) { return IntStream.of(p0,t,p1,t,p2,t); }
Example 20
Source Project: FXyzLib File: Face3.java License: GNU General Public License v3.0 | votes |
public IntStream getFace(int t0, int t1, int t2) { return IntStream.of(p0,t0,p1,t1,p2,t2); }