Search in sources :

Example 6 with DoubleStream

use of java.util.stream.DoubleStream in project junit5 by junit-team.

the class CollectionUtilsTests method toStreamWithDoubleStream.

@SuppressWarnings("unchecked")
@Test
void toStreamWithDoubleStream() {
    DoubleStream input = DoubleStream.of(42.23);
    Stream<Double> result = (Stream<Double>) CollectionUtils.toStream(input);
    assertThat(result).containsExactly(42.23);
}
Also used : DoubleStream(java.util.stream.DoubleStream) IntStream(java.util.stream.IntStream) LongStream(java.util.stream.LongStream) DoubleStream(java.util.stream.DoubleStream) Stream(java.util.stream.Stream) Test(org.junit.jupiter.api.Test) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 7 with DoubleStream

use of java.util.stream.DoubleStream in project keycloak by keycloak.

the class ClosingIntStream method asDoubleStream.

@Override
public DoubleStream asDoubleStream() {
    DoubleStream result = delegate.asDoubleStream();
    close();
    return result;
}
Also used : DoubleStream(java.util.stream.DoubleStream)

Example 8 with DoubleStream

use of java.util.stream.DoubleStream in project KursJava by SamouczekProgramisty.

the class StreamCreation method main.

public static void main(String[] args) throws FileNotFoundException {
    Stream<Integer> stream1 = new LinkedList<Integer>().stream();
    Stream<Integer> stream2 = Arrays.stream(new Integer[] {});
    Stream<String> stream3 = Pattern.compile(".").splitAsStream("some longer sentence");
    DoubleStream doubles = DoubleStream.of(1, 2, 3);
    IntStream ints = IntStream.range(0, 123);
    LongStream longs = LongStream.generate(() -> 1L);
    DoubleStream randomDoubles = new Random().doubles();
    IntStream randomInts = new Random().ints();
    LongStream randomLongs = new Random().longs();
    Stream.empty();
    try (Stream<String> lines = new BufferedReader(new FileReader("file.txt")).lines()) {
    // 
    }
}
Also used : Random(java.util.Random) BufferedReader(java.io.BufferedReader) DoubleStream(java.util.stream.DoubleStream) FileReader(java.io.FileReader) LongStream(java.util.stream.LongStream) IntStream(java.util.stream.IntStream)

Example 9 with DoubleStream

use of java.util.stream.DoubleStream in project tutorials by eugenp.

the class GuavaStreamsUnitTest method createStreamsWithOptionalDouble.

@Test
public void createStreamsWithOptionalDouble() {
    DoubleStream streamFromOptionalDouble = Streams.stream(OptionalDouble.of(1.0));
    // Assert.assertNotNull(streamFromOptionalDouble);
    assertEquals(streamFromOptionalDouble.count(), 1);
}
Also used : DoubleStream(java.util.stream.DoubleStream) Test(org.junit.Test)

Example 10 with DoubleStream

use of java.util.stream.DoubleStream in project tutorials by eugenp.

the class StreamsUtility method main.

public static void main(String[] args) {
    List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
    // Using Collection
    Stream<Integer> streamFromCollection = Streams.stream(numbers);
    // Using Iterator
    Stream<Integer> streamFromIterator = Streams.stream(numbers.iterator());
    // Using Iterable
    Stream<Integer> streamFromIterable = Streams.stream((Iterable<Integer>) numbers);
    // Using Optional
    Stream<Integer> streamFromOptional = Streams.stream(Optional.of(1));
    // Using OptionalLong to LongStream
    LongStream streamFromOptionalLong = Streams.stream(OptionalLong.of(1));
    // Using OptionalInt to IntStream
    IntStream streamFromOptionalInt = Streams.stream(OptionalInt.of(1));
    // Using OptionalDouble to DoubleStream
    DoubleStream streamFromOptionalDouble = Streams.stream(OptionalDouble.of(1.0));
    Stream<Integer> concatenatedStreams = Streams.concat(streamFromCollection, streamFromIterable, streamFromIterator);
    List<Integer> integers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    // This will return 10
    Optional<Integer> lastItem = Streams.findLast(integers.stream());
    Streams.zip(Stream.of("candy", "chocolate", "bar"), Stream.of("$1", "$2", "$3"), (arg1, arg2) -> arg1 + ":" + arg2);
}
Also used : DoubleStream(java.util.stream.DoubleStream) LongStream(java.util.stream.LongStream) IntStream(java.util.stream.IntStream)

Aggregations

DoubleStream (java.util.stream.DoubleStream)34 IntStream (java.util.stream.IntStream)11 Test (org.junit.jupiter.api.Test)10 List (java.util.List)9 Arrays (java.util.Arrays)7 Map (java.util.Map)6 Random (java.util.Random)6 Collectors (java.util.stream.Collectors)6 LongStream (java.util.stream.LongStream)6 Stream (java.util.stream.Stream)5 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 Function (java.util.function.Function)4 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)4 StorageConstants (org.apache.ignite.ml.math.StorageConstants)4 IgniteFunction (org.apache.ignite.ml.math.functions.IgniteFunction)4 SparseDistributedMatrix (org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix)4 DenseLocalOnHeapVector (org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector)4 LabeledVectorDouble (org.apache.ignite.ml.structures.LabeledVectorDouble)4