Search in sources :

Example 1 with Builder

use of java.util.stream.IntStream.Builder in project streamex by amaembo.

the class IntStreamExTest method testDropWhile.

@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());
}
Also used : IntStream(java.util.stream.IntStream) MethodSorters(org.junit.runners.MethodSorters) Arrays(java.util.Arrays) Builder(java.util.stream.IntStream.Builder) IntUnaryOperator(java.util.function.IntUnaryOperator) OfInt(java.util.PrimitiveIterator.OfInt) Spliterators(java.util.Spliterators) Assert.assertThrows(org.junit.Assert.assertThrows) Scanner(java.util.Scanner) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IntBinaryOperator(java.util.function.IntBinaryOperator) Random(java.util.Random) TestHelpers.withRandom(one.util.streamex.TestHelpers.withRandom) OptionalInt(java.util.OptionalInt) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Assert.assertSame(org.junit.Assert.assertSame) TestHelpers.intStreamEx(one.util.streamex.TestHelpers.intStreamEx) ByteArrayInputStream(java.io.ByteArrayInputStream) IntBuffer(java.nio.IntBuffer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) IntFunction(java.util.function.IntFunction) IntToDoubleFunction(java.util.function.IntToDoubleFunction) TestHelpers.checkSpliterator(one.util.streamex.TestHelpers.checkSpliterator) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) TestHelpers.streamEx(one.util.streamex.TestHelpers.streamEx) UncheckedIOException(java.io.UncheckedIOException) List(java.util.List) IntToLongFunction(java.util.function.IntToLongFunction) StreamEx(one.util.streamex.StreamEx) Assert.assertFalse(org.junit.Assert.assertFalse) IntStreamEx(one.util.streamex.IntStreamEx) BitSet(java.util.BitSet) Comparator(java.util.Comparator) FixMethodOrder(org.junit.FixMethodOrder) Collections(java.util.Collections) Spliterator(java.util.Spliterator) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) Builder(java.util.stream.IntStream.Builder) TestHelpers.checkSpliterator(one.util.streamex.TestHelpers.checkSpliterator) Spliterator(java.util.Spliterator) Test(org.junit.Test)

Example 2 with Builder

use of java.util.stream.IntStream.Builder in project servoy-client by Servoy.

the class RelatedFoundSet method getIndexesEqualsEntries.

private int[] getIndexesEqualsEntries() {
    if (equalsOpsIndexes == null) {
        Relation relation = fsm.getApplication().getFlattenedSolution().getRelation(relationName);
        Builder indexBuilder = IntStream.builder();
        int[] operators = relation.getOperators();
        for (int i = 0; i < operators.length; i++) {
            if (operators[i] == IBaseSQLCondition.EQUALS_OPERATOR) {
                indexBuilder.add(i);
            }
        }
        equalsOpsIndexes = indexBuilder.build().toArray();
    }
    return equalsOpsIndexes;
}
Also used : Relation(com.servoy.j2db.persistence.Relation) Builder(java.util.stream.IntStream.Builder)

Example 3 with Builder

use of java.util.stream.IntStream.Builder in project deephaven-core by deephaven.

the class Column method getRequiredColumns.

public IntStream getRequiredColumns() {
    Builder builder = IntStream.builder();
    builder.accept(index);
    if (formatStringColumnIndex != null) {
        builder.accept(formatStringColumnIndex);
    }
    if (styleColumnIndex != null) {
        builder.accept(styleColumnIndex);
    }
    return builder.build();
}
Also used : Builder(java.util.stream.IntStream.Builder)

Aggregations

Builder (java.util.stream.IntStream.Builder)3 Relation (com.servoy.j2db.persistence.Relation)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UncheckedIOException (java.io.UncheckedIOException)1 IntBuffer (java.nio.IntBuffer)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 BitSet (java.util.BitSet)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 OptionalInt (java.util.OptionalInt)1 OfInt (java.util.PrimitiveIterator.OfInt)1 Random (java.util.Random)1 Scanner (java.util.Scanner)1 Spliterator (java.util.Spliterator)1