Java Code Examples for java.util.stream.IntStream#builder()
The following examples show how to use
java.util.stream.IntStream#builder() .
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: termd File: Readline.java License: Apache License 2.0 | 6 votes |
private void refresh(LineBuffer update, int width) { LineBuffer copy3 = new LineBuffer(); IntStream.Builder consumer = IntStream.builder(); copy3.insert(Helper.toCodePoints(currentPrompt)); copy3.insert(buffer().toArray()); copy3.setCursor(currentPrompt.length() + buffer().getCursor()); LineBuffer copy2 = new LineBuffer(); copy2.insert(Helper.toCodePoints(currentPrompt)); copy2.insert(update.toArray()); copy2.setCursor(currentPrompt.length() + update.getCursor()); copy3.update(copy2, data -> { for (int cp : data) { consumer.accept(cp); } }, width); conn.stdoutHandler().accept(consumer.build().toArray()); buffer.clear(); buffer.insert(update.toArray()); buffer.setCursor(update.getCursor()); }
Example 2
Source Project: dragonwell8_jdk File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 3
Source Project: TencentKona-8 File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 4
Source Project: jdk8u60 File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 5
Source Project: openjdk-jdk8u File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 6
Source Project: adventure File: TagStringReader.java License: MIT License | 5 votes |
private int[] intArray() throws StringTagParseException { final IntStream.Builder builder = IntStream.builder(); while(this.buffer.hasMore()) { final BinaryTag value = this.tag(); if(!(value instanceof IntBinaryTag)) { throw this.buffer.makeError("All elements of an int array must be ints!"); } builder.add(((IntBinaryTag) value).intValue()); if(this.separatorOrCompleteWith(Tokens.ARRAY_END)) { return builder.build().toArray(); } } throw this.buffer.makeError("Reached end of document without array close"); }
Example 7
Source Project: openjdk-jdk8u-backup File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 8
Source Project: openjdk-jdk9 File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 9
Source Project: jdk8u-jdk File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 10
Source Project: hottub File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 11
Source Project: openjdk-8-source File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 12
Source Project: ViaVersion File: TagStringReader.java License: MIT License | 5 votes |
private int[] intArray() throws StringTagParseException { final IntStream.Builder builder = IntStream.builder(); while (this.buffer.hasMore()) { final Tag value = this.tag(); if (!(value instanceof IntTag)) { throw this.buffer.makeError("All elements of an int array must be ints!"); } builder.add(((IntTag) value).getValue()); if (this.separatorOrCompleteWith(Tokens.ARRAY_END)) { return builder.build().toArray(); } } throw this.buffer.makeError("Reached end of document without array close"); }
Example 13
Source Project: openjdk-8 File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 14
Source Project: jdk8u_jdk File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 15
Source Project: streams-utils File: RollingOfIntSpliterator.java License: Apache License 2.0 | 5 votes |
private IntStream buildSubstream() { IntStream.Builder subBuilder = IntStream.builder() ; for (int i = 0 ; i < grouping ; i++) { subBuilder.add(buffer[(i + bufferReadIndex.get()) % buffer.length]) ; } bufferReadIndex.incrementAndGet() ; return subBuilder.build() ; }
Example 16
Source Project: streamex File: EmitterSpliterator.java License: Apache License 2.0 | 5 votes |
@Override public void accept(int t) { if ((vals += vals < 3 ? 1 : 0) == 2) { cons = IntStream.builder(); } cons.accept(t); }
Example 17
Source Project: streamex File: IntStreamExTest.java License: Apache License 2.0 | 5 votes |
@Test public void testDropWhile() { assertArrayEquals(new int[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, IntStreamEx.range(100).dropWhile( i -> i % 10 < 5).limit(10).toArray()); assertEquals(100, IntStreamEx.range(100).dropWhile(i -> i % 10 < 0).count()); assertEquals(0, IntStreamEx.range(100).dropWhile(i -> i % 10 < 10).count()); assertEquals(OptionalInt.of(0), IntStreamEx.range(100).dropWhile(i -> i % 10 < 0).findFirst()); assertEquals(OptionalInt.empty(), IntStreamEx.range(100).dropWhile(i -> i % 10 < 10).findFirst()); java.util.Spliterator.OfInt spltr = IntStreamEx.range(100).dropWhile(i -> i % 10 < 1).spliterator(); assertTrue(spltr.tryAdvance((int x) -> assertEquals(1, x))); Builder builder = IntStream.builder(); spltr.forEachRemaining(builder); assertArrayEquals(IntStreamEx.range(2, 100).toArray(), builder.build().toArray()); }
Example 18
Source Project: jdk8u-jdk File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 19
Source Project: jdk8u-dev-jdk File: StreamBuilderTest.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "sizes") public void testIntAfterBuilding(int size) { IntStream.Builder sb = IntStream.builder(); IntStream.range(0, size).forEach(sb); sb.build(); checkISE(() -> sb.accept(1)); checkISE(() -> sb.add(1)); checkISE(() -> sb.build()); }
Example 20
Source Project: paleo File: IntColumn.java License: Apache License 2.0 | 4 votes |
private Builder(IntColumnId id) { this.id = id; this.valueBuilder = IntStream.builder(); this.metaDataBuilder = new MetaDataBuilder(); }