java.util.stream.IntStream#of ( )源码实例Demo

下面列出了java.util.stream.IntStream#of ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: rtc2jira   文件: Settings.java
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());
}
 
源代码2 项目: Java-Coding-Problems   文件: Convertors.java
public static IntStream toStream5(int[] arr) {

        if (arr == null) {
            throw new IllegalArgumentException("Inputs cannot be null");
        }

        return IntStream.of(arr);
    }
 
源代码3 项目: groovy   文件: PluginDefaultGroovyMethods.java
/**
 * 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());
}
 
源代码4 项目: TweetwallFX   文件: Tweet.java
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();
}
 
源代码5 项目: levelup-java-examples   文件: ConcatenateStream.java
@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));
}
 
@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());
}
 
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());
}
 
@Override
protected IntStream stimulus() {
    return IntStream.of(25, 50, 75);
}
 
源代码9 项目: ApprovalTests.Java   文件: NumberUtils.java
public static IntStream toIntStream(int[] numbers)
{
  return IntStream.of(numbers);
}
 
@Override
protected IntStream stimulus() {
    return IntStream.of(25, 50, 75);
}
 
protected IntStream stimulus() {
    return IntStream.of(75, 100);
}
 
源代码12 项目: RoaringBitmap   文件: RandomisedTestData.java
private static IntStream sparseRegion() {
  return IntStream.of(createSorted16BitInts(ThreadLocalRandom.current().nextInt(1, 4096)));
}
 
static IntStream intProvider() {
    return IntStream.of(0, 1);
}
 
@Override
public IntIterator getIidxUidxs(int iidx) {
    return new StreamIntIterator(IntStream.of(18, 20, 100, 101, 102));
}
 
源代码15 项目: RoaringBitmap   文件: RandomisedTestData.java
private static IntStream denseRegion() {
  return IntStream.of(createSorted16BitInts(ThreadLocalRandom.current().nextInt(4096, 1 << 16)));
}
 
源代码16 项目: blog-tutorials   文件: StreamsUpdate.java
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);
	}
 
源代码17 项目: openjdk-jdk9   文件: OptionalInt.java
/**
 * 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();
    }
}
 
源代码18 项目: Strata   文件: IntArray.java
/**
 * Returns a stream over the array values.
 *
 * @return a stream over the values in the array
 */
public IntStream stream() {
  return IntStream.of(array);
}
 
源代码19 项目: FXyzLib   文件: Face3.java
public IntStream getFace(int t) { return IntStream.of(p0,t,p1,t,p2,t); } 
源代码20 项目: FXyzLib   文件: Face3.java
public IntStream getFace(int t0, int t1, int t2) { return IntStream.of(p0,t0,p1,t1,p2,t2); }