Class DoubleStreamEx

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.util.stream.BaseStream<java.lang.Double,​java.util.stream.DoubleStream>, java.util.stream.DoubleStream

    public final class DoubleStreamEx
    extends BaseStreamEx<java.lang.Double,​java.util.stream.DoubleStream,​java.util.Spliterator.OfDouble,​DoubleStreamEx>
    implements java.util.stream.DoubleStream
    A DoubleStream implementation with additional functionality
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  DoubleStreamEx.DoubleEmitter
      A helper interface to build a new stream by emitting elements and creating new emitters in a chain.
      • Nested classes/interfaces inherited from interface java.util.stream.DoubleStream

        java.util.stream.DoubleStream.Builder
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean allMatch​(java.util.function.DoublePredicate predicate)  
      boolean anyMatch​(java.util.function.DoublePredicate predicate)  
      DoubleStreamEx append​(double... values)
      Returns a new DoubleStreamEx which is a concatenation of this stream and the stream containing supplied values
      DoubleStreamEx append​(java.util.stream.DoubleStream other)
      Creates a lazily concatenated stream whose elements are all the elements of this stream followed by all the elements of the other stream.
      DoubleStreamEx atLeast​(double value)
      Returns a stream consisting of the elements of this stream that greater than or equal to the specified value.
      DoubleStreamEx atMost​(double value)
      Returns a stream consisting of the elements of this stream that less than or equal to the specified value.
      java.util.OptionalDouble average()  
      StreamEx<java.lang.Double> boxed()  
      <U> U chain​(java.util.function.Function<? super DoubleStreamEx,​U> mapper)
      Applies the supplied function to this stream and returns the result of the function.
      <R> R collect​(java.util.function.Supplier<R> supplier, java.util.function.ObjDoubleConsumer<R> accumulator, java.util.function.BiConsumer<R,​R> combiner)
      <A,​R>
      R
      collect​(DoubleCollector<A,​R> collector)
      Performs a mutable reduction operation on the elements of this stream using an DoubleCollector which encapsulates the supplier, accumulator and merger functions making easier to reuse collection strategies.
      static DoubleStreamEx constant​(double value, long length)
      Returns a sequential unordered DoubleStreamEx of given length which elements are equal to supplied value.
      long count()  
      long count​(java.util.function.DoublePredicate predicate)
      Counts the number of elements in the stream that satisfy the predicate.
      (package private) java.util.stream.DoubleStream createStream()  
      (package private) DoubleStreamEx delegate​(java.util.Spliterator.OfDouble spliterator)  
      DoubleStreamEx distinct()  
      DoubleStreamEx dropWhile​(java.util.function.DoublePredicate predicate)
      Returns a stream consisting of all elements from this stream starting from the first element which does not match the given predicate.
      static DoubleStreamEx empty()
      Returns an empty sequential DoubleStreamEx.
      DoubleStreamEx filter​(java.util.function.DoublePredicate predicate)  
      java.util.OptionalDouble findAny()  
      java.util.OptionalDouble findAny​(java.util.function.DoublePredicate predicate)
      Returns an OptionalDouble describing some element of the stream, which matches given predicate, or an empty OptionalDouble if there's no matching element.
      java.util.OptionalDouble findFirst()  
      java.util.OptionalDouble findFirst​(java.util.function.DoublePredicate predicate)
      Returns an OptionalDouble describing the first element of this stream, which matches given predicate, or an empty OptionalDouble if there's no matching element.
      DoubleStreamEx flatMap​(java.util.function.DoubleFunction<? extends java.util.stream.DoubleStream> mapper)  
      IntStreamEx flatMapToInt​(java.util.function.DoubleFunction<? extends java.util.stream.IntStream> mapper)
      Returns an IntStreamEx consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
      LongStreamEx flatMapToLong​(java.util.function.DoubleFunction<? extends java.util.stream.LongStream> mapper)
      Returns a LongStreamEx consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
      <R> StreamEx<R> flatMapToObj​(java.util.function.DoubleFunction<? extends java.util.stream.Stream<R>> mapper)
      Returns a StreamEx consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
      double foldLeft​(double seed, java.util.function.DoubleBinaryOperator accumulator)
      Folds the elements of this stream using the provided seed object and accumulation function, going left to right.
      java.util.OptionalDouble foldLeft​(java.util.function.DoubleBinaryOperator accumulator)
      Folds the elements of this stream using the provided accumulation function, going left to right.
      void forEach​(java.util.function.DoubleConsumer action)  
      void forEachOrdered​(java.util.function.DoubleConsumer action)  
      static DoubleStreamEx generate​(java.util.function.DoubleSupplier s)
      Returns an infinite sequential unordered stream where each element is generated by the provided DoubleSupplier.
      DoubleStreamEx greater​(double value)
      Returns a stream consisting of the elements of this stream that strictly greater than the specified value.
      java.util.OptionalLong indexOf​(java.util.function.DoublePredicate predicate)
      Returns an OptionalLong describing the zero-based index of the first element of this stream, which matches given predicate, or an empty OptionalLong if there's no matching element.
      DoubleStreamEx intersperse​(int delimiter)
      Returns a new stream containing all the elements of the original stream interspersed with given delimiter.
      static DoubleStreamEx iterate​(double seed, java.util.function.DoublePredicate predicate, java.util.function.DoubleUnaryOperator f)
      Returns a sequential ordered DoubleStreamEx produced by iterative application of a function to an initial element, conditioned on satisfying the supplied predicate.
      static DoubleStreamEx iterate​(double seed, java.util.function.DoubleUnaryOperator f)
      Returns an infinite sequential ordered DoubleStreamEx produced by iterative application of a function f to an initial element seed, producing a stream consisting of seed, f(seed), f(f(seed)), etc.
      java.util.PrimitiveIterator.OfDouble iterator()  
      java.lang.String joining​(java.lang.CharSequence delimiter)
      Returns a String which is the concatenation of the results of calling String.valueOf(double) on each element of this stream, separated by the specified delimiter, in encounter order.
      java.lang.String joining​(java.lang.CharSequence delimiter, java.lang.CharSequence prefix, java.lang.CharSequence suffix)
      Returns a String which is the concatenation of the results of calling String.valueOf(double) on each element of this stream, separated by the specified delimiter, with the specified prefix and suffix in encounter order.
      DoubleStreamEx less​(double value)
      Returns a stream consisting of the elements of this stream that strictly less than the specified value.
      DoubleStreamEx limit​(long maxSize)  
      DoubleStreamEx map​(java.util.function.DoubleUnaryOperator mapper)  
      DoubleStreamEx mapFirst​(java.util.function.DoubleUnaryOperator mapper)
      Returns a stream where the first element is the replaced with the result of applying the given function while the other elements are left intact.
      DoubleStreamEx mapLast​(java.util.function.DoubleUnaryOperator mapper)
      Returns a stream where the last element is the replaced with the result of applying the given function while the other elements are left intact.
      <K,​V>
      EntryStream<K,​V>
      mapToEntry​(java.util.function.DoubleFunction<? extends K> keyMapper, java.util.function.DoubleFunction<? extends V> valueMapper)
      Returns an EntryStream consisting of the Map.Entry objects which keys and values are results of applying the given functions to the elements of this stream.
      IntStreamEx mapToInt​(java.util.function.DoubleToIntFunction mapper)  
      LongStreamEx mapToLong​(java.util.function.DoubleToLongFunction mapper)  
      <U> StreamEx<U> mapToObj​(java.util.function.DoubleFunction<? extends U> mapper)  
      java.util.OptionalDouble max()  
      java.util.OptionalDouble max​(java.util.Comparator<java.lang.Double> comparator)
      Returns the maximum element of this stream according to the provided Comparator.
      <V extends java.lang.Comparable<? super V>>
      java.util.OptionalDouble
      maxBy​(java.util.function.DoubleFunction<V> keyExtractor)
      Returns the maximum element of this stream according to the provided key extractor function.
      java.util.OptionalDouble maxByDouble​(java.util.function.DoubleUnaryOperator keyExtractor)
      Returns the maximum element of this stream according to the provided key extractor function.
      java.util.OptionalDouble maxByInt​(java.util.function.DoubleToIntFunction keyExtractor)
      Returns the maximum element of this stream according to the provided key extractor function.
      java.util.OptionalDouble maxByLong​(java.util.function.DoubleToLongFunction keyExtractor)
      Returns the maximum element of this stream according to the provided key extractor function.
      java.util.OptionalDouble min()  
      java.util.OptionalDouble min​(java.util.Comparator<java.lang.Double> comparator)
      Returns the minimum element of this stream according to the provided Comparator.
      <V extends java.lang.Comparable<? super V>>
      java.util.OptionalDouble
      minBy​(java.util.function.DoubleFunction<V> keyExtractor)
      Returns the minimum element of this stream according to the provided key extractor function.
      java.util.OptionalDouble minByDouble​(java.util.function.DoubleUnaryOperator keyExtractor)
      Returns the minimum element of this stream according to the provided key extractor function.
      java.util.OptionalDouble minByInt​(java.util.function.DoubleToIntFunction keyExtractor)
      Returns the minimum element of this stream according to the provided key extractor function.
      java.util.OptionalDouble minByLong​(java.util.function.DoubleToLongFunction keyExtractor)
      Returns the minimum element of this stream according to the provided key extractor function.
      boolean noneMatch​(java.util.function.DoublePredicate predicate)  
      static DoubleStreamEx of​(double element)
      Returns a sequential DoubleStreamEx containing a single element.
      static DoubleStreamEx of​(double... elements)
      Returns a sequential ordered DoubleStreamEx whose elements are the specified values.
      static DoubleStreamEx of​(double[] array, int startInclusive, int endExclusive)
      Returns a sequential DoubleStreamEx with the specified range of the specified array as its source.
      static DoubleStreamEx of​(float... elements)
      Returns a sequential ordered DoubleStreamEx whose elements are the specified float values casted to double.
      static DoubleStreamEx of​(float[] array, int startInclusive, int endExclusive)
      Returns a sequential DoubleStreamEx with the specified range of the specified array as its source.
      static DoubleStreamEx of​(java.lang.Double[] array)
      Returns a sequential ordered DoubleStreamEx whose elements are the unboxed elements of supplied array.
      static DoubleStreamEx of​(java.nio.DoubleBuffer buf)
      Returns a sequential ordered DoubleStreamEx whose elements are the values in the supplied DoubleBuffer.
      static DoubleStreamEx of​(java.util.Collection<java.lang.Double> collection)
      Returns a sequential ordered DoubleStreamEx whose elements are the unboxed elements of supplied collection.
      static DoubleStreamEx of​(java.util.OptionalDouble optional)
      Returns a sequential DoubleStreamEx containing an OptionalDouble value, if present, otherwise returns an empty DoubleStreamEx.
      static DoubleStreamEx of​(java.util.PrimitiveIterator.OfDouble iterator)
      Returns a sequential, ordered DoubleStreamEx created from given PrimitiveIterator.OfDouble.
      static DoubleStreamEx of​(java.util.Random random)
      Returns an effectively unlimited stream of pseudorandom double values, each between zero (inclusive) and one (exclusive) produced by given Random object.
      static DoubleStreamEx of​(java.util.Random random, double randomNumberOrigin, double randomNumberBound)
      Returns an effectively unlimited stream of pseudorandom double values, each conforming to the given origin (inclusive) and bound (exclusive) produced by given Random object.
      static DoubleStreamEx of​(java.util.Random random, long streamSize)
      Returns a stream producing the given streamSize number of pseudorandom double values, each between zero (inclusive) and one (exclusive) produced by given Random object.
      static DoubleStreamEx of​(java.util.Random random, long streamSize, double randomNumberOrigin, double randomNumberBound)
      Returns a stream producing the given streamSize number of pseudorandom double values, each conforming to the given origin (inclusive) and bound (exclusive) produced by given Random object.
      static DoubleStreamEx of​(java.util.Spliterator.OfDouble spliterator)
      Returns a sequential DoubleStreamEx created from given Spliterator.OfDouble.
      static DoubleStreamEx of​(java.util.stream.DoubleStream stream)
      Returns a DoubleStreamEx object which wraps given DoubleStream.
      DoubleStreamEx onClose​(java.lang.Runnable closeHandler)  
      DoubleStreamEx pairMap​(java.util.function.DoubleBinaryOperator mapper)
      Returns a stream consisting of the results of applying the given function to the every adjacent pair of elements of this stream.
      DoubleStreamEx parallel()
      DoubleStreamEx parallel​(java.util.concurrent.ForkJoinPool fjp)
      Returns an equivalent stream that is parallel and bound to the supplied ForkJoinPool.
      DoubleStreamEx peek​(java.util.function.DoubleConsumer action)  
      DoubleStreamEx peekFirst​(java.util.function.DoubleConsumer action)
      Returns a stream consisting of the elements of this stream, additionally performing the provided action on the first stream element when it's consumed from the resulting stream.
      DoubleStreamEx peekLast​(java.util.function.DoubleConsumer action)
      Returns a stream consisting of the elements of this stream, additionally performing the provided action on the last stream element when it's consumed from the resulting stream.
      DoubleStreamEx prefix​(java.util.function.DoubleBinaryOperator op)
      Returns a stream containing cumulative results of applying the accumulation function going left to right.
      DoubleStreamEx prepend​(double... values)
      Returns a new DoubleStreamEx which is a concatenation of the stream containing supplied values and this stream
      DoubleStreamEx prepend​(java.util.stream.DoubleStream other)
      Creates a lazily concatenated stream whose elements are all the elements of the other stream followed by all the elements of this stream.
      static DoubleStreamEx produce​(java.util.function.Predicate<java.util.function.DoubleConsumer> producer)
      Return an ordered stream produced by consecutive calls of the supplied producer until it returns false.
      double reduce​(double identity, java.util.function.DoubleBinaryOperator op)  
      java.util.OptionalDouble reduce​(java.util.function.DoubleBinaryOperator op)  
      DoubleStreamEx remove​(java.util.function.DoublePredicate predicate)
      Returns a stream consisting of the elements of this stream that don't match the given predicate.
      DoubleStreamEx reverseSorted()
      Returns a stream consisting of the elements of this stream in reverse sorted order.
      double[] scanLeft​(double seed, java.util.function.DoubleBinaryOperator accumulator)
      Produces an array containing cumulative results of applying the accumulation function going left to right using given seed value.
      double[] scanLeft​(java.util.function.DoubleBinaryOperator accumulator)
      Produces an array containing cumulative results of applying the accumulation function going left to right.
      private static DoubleStreamEx seq​(java.util.stream.DoubleStream stream)  
      DoubleStreamEx sequential()  
      DoubleStreamEx skip​(long n)  
      DoubleStreamEx sorted()  
      DoubleStreamEx sorted​(java.util.Comparator<java.lang.Double> comparator)
      Returns a stream consisting of the elements of this stream sorted according to the given comparator.
      <V extends java.lang.Comparable<? super V>>
      DoubleStreamEx
      sortedBy​(java.util.function.DoubleFunction<V> keyExtractor)
      Returns a stream consisting of the elements of this stream, sorted according to the natural order of the keys extracted by provided function.
      DoubleStreamEx sortedByDouble​(java.util.function.DoubleUnaryOperator keyExtractor)
      Returns a stream consisting of the elements of this stream, sorted according to the double values extracted by provided function.
      DoubleStreamEx sortedByInt​(java.util.function.DoubleToIntFunction keyExtractor)
      Returns a stream consisting of the elements of this stream, sorted according to the int values extracted by provided function.
      DoubleStreamEx sortedByLong​(java.util.function.DoubleToLongFunction keyExtractor)
      Returns a stream consisting of the elements of this stream, sorted according to the long values extracted by provided function.
      double sum()  
      java.util.DoubleSummaryStatistics summaryStatistics()  
      DoubleStreamEx takeWhile​(java.util.function.DoublePredicate predicate)
      Returns a stream consisting of all elements from this stream until the first element which does not match the given predicate is found.
      DoubleStreamEx takeWhileInclusive​(java.util.function.DoublePredicate predicate)
      Returns a stream consisting of all elements from this stream until the first element which does not match the given predicate is found (including the first mismatching element).
      double[] toArray()  
      float[] toFloatArray()
      Returns a float[] array containing the elements of this stream which are converted to floats using (float) cast operation.
      DoubleStreamEx unordered()  
      static DoubleStreamEx zip​(double[] first, double[] second, java.util.function.DoubleBinaryOperator mapper)
      Returns a sequential DoubleStreamEx containing the results of applying the given function to the corresponding pairs of values in given two arrays.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.stream.BaseStream

        close, isParallel
      • Methods inherited from interface java.util.stream.DoubleStream

        spliterator
    • Constructor Detail

      • DoubleStreamEx

        DoubleStreamEx​(java.util.stream.DoubleStream stream,
                       StreamContext context)
      • DoubleStreamEx

        DoubleStreamEx​(java.util.Spliterator.OfDouble spliterator,
                       StreamContext context)
    • Method Detail

      • createStream

        java.util.stream.DoubleStream createStream()
        Specified by:
        createStream in class BaseStreamEx<java.lang.Double,​java.util.stream.DoubleStream,​java.util.Spliterator.OfDouble,​DoubleStreamEx>
      • seq

        private static DoubleStreamEx seq​(java.util.stream.DoubleStream stream)
      • delegate

        DoubleStreamEx delegate​(java.util.Spliterator.OfDouble spliterator)
      • unordered

        public DoubleStreamEx unordered()
        Specified by:
        unordered in interface java.util.stream.BaseStream<java.lang.Double,​java.util.stream.DoubleStream>
        Overrides:
        unordered in class BaseStreamEx<java.lang.Double,​java.util.stream.DoubleStream,​java.util.Spliterator.OfDouble,​DoubleStreamEx>
      • onClose

        public DoubleStreamEx onClose​(java.lang.Runnable closeHandler)
        Specified by:
        onClose in interface java.util.stream.BaseStream<java.lang.Double,​java.util.stream.DoubleStream>
        Overrides:
        onClose in class BaseStreamEx<java.lang.Double,​java.util.stream.DoubleStream,​java.util.Spliterator.OfDouble,​DoubleStreamEx>
      • filter

        public DoubleStreamEx filter​(java.util.function.DoublePredicate predicate)
        Specified by:
        filter in interface java.util.stream.DoubleStream
      • remove

        public DoubleStreamEx remove​(java.util.function.DoublePredicate predicate)
        Returns a stream consisting of the elements of this stream that don't match the given predicate.

        This is an intermediate operation.

        Parameters:
        predicate - a non-interfering, stateless predicate to apply to each element to determine if it should be excluded
        Returns:
        the new stream
      • greater

        public DoubleStreamEx greater​(double value)
        Returns a stream consisting of the elements of this stream that strictly greater than the specified value.

        This is an intermediate operation.

        Parameters:
        value - a value to compare to
        Returns:
        the new stream
        Since:
        0.2.3
      • less

        public DoubleStreamEx less​(double value)
        Returns a stream consisting of the elements of this stream that strictly less than the specified value.

        This is an intermediate operation.

        Parameters:
        value - a value to compare to
        Returns:
        the new stream
        Since:
        0.2.3
      • atLeast

        public DoubleStreamEx atLeast​(double value)
        Returns a stream consisting of the elements of this stream that greater than or equal to the specified value.

        This is an intermediate operation.

        Parameters:
        value - a value to compare to
        Returns:
        the new stream
        Since:
        0.2.3
      • atMost

        public DoubleStreamEx atMost​(double value)
        Returns a stream consisting of the elements of this stream that less than or equal to the specified value.

        This is an intermediate operation.

        Parameters:
        value - a value to compare to
        Returns:
        the new stream
        Since:
        0.2.3
      • map

        public DoubleStreamEx map​(java.util.function.DoubleUnaryOperator mapper)
        Specified by:
        map in interface java.util.stream.DoubleStream
      • mapFirst

        public DoubleStreamEx mapFirst​(java.util.function.DoubleUnaryOperator mapper)
        Returns a stream where the first element is the replaced with the result of applying the given function while the other elements are left intact.

        This is a quasi-intermediate operation.

        Parameters:
        mapper - a non-interfering , stateless function to apply to the first element
        Returns:
        the new stream
        Since:
        0.4.1
      • mapLast

        public DoubleStreamEx mapLast​(java.util.function.DoubleUnaryOperator mapper)
        Returns a stream where the last element is the replaced with the result of applying the given function while the other elements are left intact.

        This is a quasi-intermediate operation.

        The mapper function is called at most once. It could be not called at all if the stream is empty or there is short-circuiting operation downstream.

        Parameters:
        mapper - a non-interfering , stateless function to apply to the last element
        Returns:
        the new stream
        Since:
        0.4.1
      • mapToObj

        public <U> StreamEx<U> mapToObj​(java.util.function.DoubleFunction<? extends U> mapper)
        Specified by:
        mapToObj in interface java.util.stream.DoubleStream
      • mapToInt

        public IntStreamEx mapToInt​(java.util.function.DoubleToIntFunction mapper)
        Specified by:
        mapToInt in interface java.util.stream.DoubleStream
      • mapToLong

        public LongStreamEx mapToLong​(java.util.function.DoubleToLongFunction mapper)
        Specified by:
        mapToLong in interface java.util.stream.DoubleStream
      • mapToEntry

        public <K,​V> EntryStream<K,​V> mapToEntry​(java.util.function.DoubleFunction<? extends K> keyMapper,
                                                             java.util.function.DoubleFunction<? extends V> valueMapper)
        Returns an EntryStream consisting of the Map.Entry objects which keys and values are results of applying the given functions to the elements of this stream.

        This is an intermediate operation.

        Type Parameters:
        K - The Entry key type
        V - The Entry value type
        Parameters:
        keyMapper - a non-interfering, stateless function to apply to each element
        valueMapper - a non-interfering, stateless function to apply to each element
        Returns:
        the new stream
        Since:
        0.3.1
      • flatMap

        public DoubleStreamEx flatMap​(java.util.function.DoubleFunction<? extends java.util.stream.DoubleStream> mapper)
        Specified by:
        flatMap in interface java.util.stream.DoubleStream
      • flatMapToInt

        public IntStreamEx flatMapToInt​(java.util.function.DoubleFunction<? extends java.util.stream.IntStream> mapper)
        Returns an IntStreamEx consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

        This is an intermediate operation.

        Parameters:
        mapper - a non-interfering, stateless function to apply to each element which produces an IntStream of new values
        Returns:
        the new stream
        Since:
        0.3.0
      • flatMapToLong

        public LongStreamEx flatMapToLong​(java.util.function.DoubleFunction<? extends java.util.stream.LongStream> mapper)
        Returns a LongStreamEx consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

        This is an intermediate operation.

        Parameters:
        mapper - a non-interfering, stateless function to apply to each element which produces a LongStream of new values
        Returns:
        the new stream
        Since:
        0.3.0
      • flatMapToObj

        public <R> StreamEx<R> flatMapToObj​(java.util.function.DoubleFunction<? extends java.util.stream.Stream<R>> mapper)
        Returns a StreamEx consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

        This is an intermediate operation.

        Type Parameters:
        R - The element type of the new stream
        Parameters:
        mapper - a non-interfering, stateless function to apply to each element which produces a Stream of new values
        Returns:
        the new stream
        Since:
        0.3.0
      • intersperse

        public DoubleStreamEx intersperse​(int delimiter)
        Returns a new stream containing all the elements of the original stream interspersed with given delimiter.

        For example, DoubleStreamEx.of(1, 2, 3).intersperse(4) will yield a stream containing five elements: 1, 4, 2, 4, 3.

        This is an intermediate operation.

        Parameters:
        delimiter - a delimiter to be inserted between each pair of elements
        Returns:
        the new stream
        Since:
        0.6.6
      • distinct

        public DoubleStreamEx distinct()
        Specified by:
        distinct in interface java.util.stream.DoubleStream
      • sorted

        public DoubleStreamEx sorted()
        Specified by:
        sorted in interface java.util.stream.DoubleStream
      • sorted

        public DoubleStreamEx sorted​(java.util.Comparator<java.lang.Double> comparator)
        Returns a stream consisting of the elements of this stream sorted according to the given comparator. Stream elements are boxed before passing to the comparator.

        For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

        This is a stateful intermediate operation.

        Parameters:
        comparator - a non-interfering , stateless Comparator to be used to compare stream elements
        Returns:
        the new stream
      • reverseSorted

        public DoubleStreamEx reverseSorted()
        Returns a stream consisting of the elements of this stream in reverse sorted order. The elements are compared for equality according to Double.compare(double, double).

        This is a stateful intermediate operation.

        Returns:
        the new stream
        Since:
        0.0.8
      • sortedBy

        public <V extends java.lang.Comparable<? super V>> DoubleStreamEx sortedBy​(java.util.function.DoubleFunction<V> keyExtractor)
        Returns a stream consisting of the elements of this stream, sorted according to the natural order of the keys extracted by provided function.

        For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

        This is a stateful intermediate operation.

        Type Parameters:
        V - the type of the Comparable sort key
        Parameters:
        keyExtractor - a non-interfering , stateless function to be used to extract sorting keys
        Returns:
        the new stream
      • sortedByInt

        public DoubleStreamEx sortedByInt​(java.util.function.DoubleToIntFunction keyExtractor)
        Returns a stream consisting of the elements of this stream, sorted according to the int values extracted by provided function.

        For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

        This is a stateful intermediate operation.

        Parameters:
        keyExtractor - a non-interfering , stateless function to be used to extract sorting keys
        Returns:
        the new stream
      • sortedByLong

        public DoubleStreamEx sortedByLong​(java.util.function.DoubleToLongFunction keyExtractor)
        Returns a stream consisting of the elements of this stream, sorted according to the long values extracted by provided function.

        For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

        This is a stateful intermediate operation.

        Parameters:
        keyExtractor - a non-interfering , stateless function to be used to extract sorting keys
        Returns:
        the new stream
      • sortedByDouble

        public DoubleStreamEx sortedByDouble​(java.util.function.DoubleUnaryOperator keyExtractor)
        Returns a stream consisting of the elements of this stream, sorted according to the double values extracted by provided function.

        For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

        This is a stateful intermediate operation.

        Parameters:
        keyExtractor - a non-interfering , stateless function to be used to extract sorting keys
        Returns:
        the new stream
      • peek

        public DoubleStreamEx peek​(java.util.function.DoubleConsumer action)
        Specified by:
        peek in interface java.util.stream.DoubleStream
      • peekFirst

        public DoubleStreamEx peekFirst​(java.util.function.DoubleConsumer action)
        Returns a stream consisting of the elements of this stream, additionally performing the provided action on the first stream element when it's consumed from the resulting stream.

        This is an intermediate operation.

        The action is called at most once. For parallel stream pipelines, it's not guaranteed in which thread it will be executed, so if it modifies shared state, it is responsible for providing the required synchronization.

        Note that the action might not be called at all if the first element is not consumed from the input (for example, if there's short-circuiting operation downstream which stopped the stream before the first element).

        This method exists mainly to support debugging.

        Parameters:
        action - a non-interfering action to perform on the first stream element as it is consumed from the stream
        Returns:
        the new stream
        Since:
        0.6.0
      • peekLast

        public DoubleStreamEx peekLast​(java.util.function.DoubleConsumer action)
        Returns a stream consisting of the elements of this stream, additionally performing the provided action on the last stream element when it's consumed from the resulting stream.

        This is an intermediate operation.

        The action is called at most once. For parallel stream pipelines, it's not guaranteed in which thread it will be executed, so if it modifies shared state, it is responsible for providing the required synchronization.

        Note that the action might not be called at all if the last element is not consumed from the input (for example, if there's short-circuiting operation downstream).

        This method exists mainly to support debugging.

        Parameters:
        action - a non-interfering action to perform on the first stream element as it is consumed from the stream
        Returns:
        the new stream
        Since:
        0.6.0
      • limit

        public DoubleStreamEx limit​(long maxSize)
        Specified by:
        limit in interface java.util.stream.DoubleStream
      • skip

        public DoubleStreamEx skip​(long n)
        Specified by:
        skip in interface java.util.stream.DoubleStream
      • forEach

        public void forEach​(java.util.function.DoubleConsumer action)
        Specified by:
        forEach in interface java.util.stream.DoubleStream
      • forEachOrdered

        public void forEachOrdered​(java.util.function.DoubleConsumer action)
        Specified by:
        forEachOrdered in interface java.util.stream.DoubleStream
      • toArray

        public double[] toArray()
        Specified by:
        toArray in interface java.util.stream.DoubleStream
      • toFloatArray

        public float[] toFloatArray()
        Returns a float[] array containing the elements of this stream which are converted to floats using (float) cast operation.

        This is a terminal operation.

        Returns:
        an array containing the elements of this stream
        Since:
        0.3.0
      • reduce

        public double reduce​(double identity,
                             java.util.function.DoubleBinaryOperator op)
        Specified by:
        reduce in interface java.util.stream.DoubleStream
      • reduce

        public java.util.OptionalDouble reduce​(java.util.function.DoubleBinaryOperator op)
        Specified by:
        reduce in interface java.util.stream.DoubleStream
      • foldLeft

        public java.util.OptionalDouble foldLeft​(java.util.function.DoubleBinaryOperator accumulator)
        Folds the elements of this stream using the provided accumulation function, going left to right. This is equivalent to:
         
             boolean foundAny = false;
             double result = 0;
             for (double element : this stream) {
                 if (!foundAny) {
                     foundAny = true;
                     result = element;
                 }
                 else
                     result = accumulator.apply(result, element);
             }
             return foundAny ? OptionalDouble.of(result) : OptionalDouble.empty();
         
         

        This is a terminal operation.

        This method cannot take all the advantages of parallel streams as it must process elements strictly left to right. If your accumulator function is associative, consider using reduce(DoubleBinaryOperator) method.

        For parallel stream it's not guaranteed that accumulator will always be executed in the same thread.

        Parameters:
        accumulator - a non-interfering , stateless function for incorporating an additional element into a result
        Returns:
        the result of the folding
        Since:
        0.4.0
        See Also:
        foldLeft(double, DoubleBinaryOperator), reduce(DoubleBinaryOperator)
      • foldLeft

        public double foldLeft​(double seed,
                               java.util.function.DoubleBinaryOperator accumulator)
        Folds the elements of this stream using the provided seed object and accumulation function, going left to right. This is equivalent to:
         
             double result = identity;
             for (double element : this stream)
                 result = accumulator.apply(result, element)
             return result;
         
         

        This is a terminal operation.

        This method cannot take all the advantages of parallel streams as it must process elements strictly left to right. If your accumulator function is associative, consider using reduce(double, DoubleBinaryOperator) method.

        For parallel stream it's not guaranteed that accumulator will always be executed in the same thread.

        Parameters:
        seed - the starting value
        accumulator - a non-interfering , stateless function for incorporating an additional element into a result
        Returns:
        the result of the folding
        Since:
        0.4.0
        See Also:
        reduce(double, DoubleBinaryOperator), foldLeft(DoubleBinaryOperator)
      • scanLeft

        public double[] scanLeft​(java.util.function.DoubleBinaryOperator accumulator)
        Produces an array containing cumulative results of applying the accumulation function going left to right.

        This is a terminal operation.

        For parallel stream it's not guaranteed that accumulator will always be executed in the same thread.

        This method cannot take all the advantages of parallel streams as it must process elements strictly left to right.

        Parameters:
        accumulator - a non-interfering , stateless function for incorporating an additional element into a result
        Returns:
        the array where the first element is the first element of this stream and every successor element is the result of applying accumulator function to the previous array element and the corresponding stream element. The resulting array has the same length as this stream.
        Since:
        0.5.1
        See Also:
        foldLeft(DoubleBinaryOperator)
      • scanLeft

        public double[] scanLeft​(double seed,
                                 java.util.function.DoubleBinaryOperator accumulator)
        Produces an array containing cumulative results of applying the accumulation function going left to right using given seed value.

        This is a terminal operation.

        For parallel stream it's not guaranteed that accumulator will always be executed in the same thread.

        This method cannot take all the advantages of parallel streams as it must process elements strictly left to right.

        Parameters:
        seed - the starting value
        accumulator - a non-interfering , stateless function for incorporating an additional element into a result
        Returns:
        the array where the first element is the seed and every successor element is the result of applying accumulator function to the previous array element and the corresponding stream element. The resulting array is one element longer than this stream.
        Since:
        0.5.1
        See Also:
        foldLeft(double, DoubleBinaryOperator)
      • collect

        public <R> R collect​(java.util.function.Supplier<R> supplier,
                             java.util.function.ObjDoubleConsumer<R> accumulator,
                             java.util.function.BiConsumer<R,​R> combiner)
        Specified by:
        collect in interface java.util.stream.DoubleStream
        See Also:
        collect(DoubleCollector)
      • collect

        public <A,​R> R collect​(DoubleCollector<A,​R> collector)
        Performs a mutable reduction operation on the elements of this stream using an DoubleCollector which encapsulates the supplier, accumulator and merger functions making easier to reuse collection strategies.

        Like reduce(double, DoubleBinaryOperator), collect operations can be parallelized without requiring additional synchronization.

        This is a terminal operation.

        Type Parameters:
        A - the intermediate accumulation type of the DoubleCollector
        R - type of the result
        Parameters:
        collector - the DoubleCollector describing the reduction
        Returns:
        the result of the reduction
        Since:
        0.3.0
        See Also:
        collect(Supplier, ObjDoubleConsumer, BiConsumer)
      • sum

        public double sum()
        Specified by:
        sum in interface java.util.stream.DoubleStream
      • min

        public java.util.OptionalDouble min()
        Specified by:
        min in interface java.util.stream.DoubleStream
      • min

        public java.util.OptionalDouble min​(java.util.Comparator<java.lang.Double> comparator)
        Returns the minimum element of this stream according to the provided Comparator.

        This is a terminal operation.

        Parameters:
        comparator - a non-interfering, stateless Comparator to compare elements of this stream
        Returns:
        an OptionalDouble describing the minimum element of this stream, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • minBy

        public <V extends java.lang.Comparable<? super V>> java.util.OptionalDouble minBy​(java.util.function.DoubleFunction<V> keyExtractor)
        Returns the minimum element of this stream according to the provided key extractor function.

        This is a terminal operation.

        Type Parameters:
        V - the type of the Comparable sort key
        Parameters:
        keyExtractor - a non-interfering, stateless function
        Returns:
        an OptionalDouble describing the first element of this stream for which the lowest value was returned by key extractor, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • minByInt

        public java.util.OptionalDouble minByInt​(java.util.function.DoubleToIntFunction keyExtractor)
        Returns the minimum element of this stream according to the provided key extractor function.

        This is a terminal operation.

        Parameters:
        keyExtractor - a non-interfering, stateless function
        Returns:
        an OptionalDouble describing the first element of this stream for which the lowest value was returned by key extractor, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • minByLong

        public java.util.OptionalDouble minByLong​(java.util.function.DoubleToLongFunction keyExtractor)
        Returns the minimum element of this stream according to the provided key extractor function.

        This is a terminal operation.

        Parameters:
        keyExtractor - a non-interfering, stateless function
        Returns:
        an OptionalDouble describing the first element of this stream for which the lowest value was returned by key extractor, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • minByDouble

        public java.util.OptionalDouble minByDouble​(java.util.function.DoubleUnaryOperator keyExtractor)
        Returns the minimum element of this stream according to the provided key extractor function.

        This is a terminal operation.

        Parameters:
        keyExtractor - a non-interfering, stateless function
        Returns:
        an OptionalDouble describing the first element of this stream for which the lowest value was returned by key extractor, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • max

        public java.util.OptionalDouble max()
        Specified by:
        max in interface java.util.stream.DoubleStream
      • max

        public java.util.OptionalDouble max​(java.util.Comparator<java.lang.Double> comparator)
        Returns the maximum element of this stream according to the provided Comparator.

        This is a terminal operation.

        Parameters:
        comparator - a non-interfering, stateless Comparator to compare elements of this stream
        Returns:
        an OptionalDouble describing the maximum element of this stream, or an empty OptionalDouble if the stream is empty
      • maxBy

        public <V extends java.lang.Comparable<? super V>> java.util.OptionalDouble maxBy​(java.util.function.DoubleFunction<V> keyExtractor)
        Returns the maximum element of this stream according to the provided key extractor function.

        This is a terminal operation.

        Type Parameters:
        V - the type of the Comparable sort key
        Parameters:
        keyExtractor - a non-interfering, stateless function
        Returns:
        an OptionalDouble describing the first element of this stream for which the highest value was returned by key extractor, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • maxByInt

        public java.util.OptionalDouble maxByInt​(java.util.function.DoubleToIntFunction keyExtractor)
        Returns the maximum element of this stream according to the provided key extractor function.

        This is a terminal operation.

        Parameters:
        keyExtractor - a non-interfering, stateless function
        Returns:
        an OptionalDouble describing the first element of this stream for which the highest value was returned by key extractor, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • maxByLong

        public java.util.OptionalDouble maxByLong​(java.util.function.DoubleToLongFunction keyExtractor)
        Returns the maximum element of this stream according to the provided key extractor function.

        This is a terminal operation.

        Parameters:
        keyExtractor - a non-interfering, stateless function
        Returns:
        an OptionalDouble describing the first element of this stream for which the highest value was returned by key extractor, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • maxByDouble

        public java.util.OptionalDouble maxByDouble​(java.util.function.DoubleUnaryOperator keyExtractor)
        Returns the maximum element of this stream according to the provided key extractor function.

        This is a terminal operation.

        Parameters:
        keyExtractor - a non-interfering, stateless function
        Returns:
        an OptionalDouble describing the first element of this stream for which the highest value was returned by key extractor, or an empty OptionalDouble if the stream is empty
        Since:
        0.1.2
      • count

        public long count()
        Specified by:
        count in interface java.util.stream.DoubleStream
      • count

        public long count​(java.util.function.DoublePredicate predicate)
        Counts the number of elements in the stream that satisfy the predicate.

        This is a terminal operation.

        Parameters:
        predicate - a non-interfering , stateless predicate to apply to stream elements. Only elements passing the predicate will be counted.
        Returns:
        the count of elements in this stream satisfying the predicate.
      • average

        public java.util.OptionalDouble average()
        Specified by:
        average in interface java.util.stream.DoubleStream
      • summaryStatistics

        public java.util.DoubleSummaryStatistics summaryStatistics()
        Specified by:
        summaryStatistics in interface java.util.stream.DoubleStream
      • anyMatch

        public boolean anyMatch​(java.util.function.DoublePredicate predicate)
        Specified by:
        anyMatch in interface java.util.stream.DoubleStream
      • allMatch

        public boolean allMatch​(java.util.function.DoublePredicate predicate)
        Specified by:
        allMatch in interface java.util.stream.DoubleStream
      • noneMatch

        public boolean noneMatch​(java.util.function.DoublePredicate predicate)
        Specified by:
        noneMatch in interface java.util.stream.DoubleStream
      • findFirst

        public java.util.OptionalDouble findFirst()
        Specified by:
        findFirst in interface java.util.stream.DoubleStream
      • findFirst

        public java.util.OptionalDouble findFirst​(java.util.function.DoublePredicate predicate)
        Returns an OptionalDouble describing the first element of this stream, which matches given predicate, or an empty OptionalDouble if there's no matching element.

        This is a short-circuiting terminal operation.

        Parameters:
        predicate - a non-interfering , stateless predicate which returned value should match
        Returns:
        an OptionalDouble describing the first matching element of this stream, or an empty OptionalDouble if there's no matching element
        See Also:
        findFirst()
      • findAny

        public java.util.OptionalDouble findAny()
        Specified by:
        findAny in interface java.util.stream.DoubleStream
      • findAny

        public java.util.OptionalDouble findAny​(java.util.function.DoublePredicate predicate)
        Returns an OptionalDouble describing some element of the stream, which matches given predicate, or an empty OptionalDouble if there's no matching element.

        This is a short-circuiting terminal operation.

        The behavior of this operation is explicitly nondeterministic; it is free to select any element in the stream. This is to allow for maximal performance in parallel operations; the cost is that multiple invocations on the same source may not return the same result. (If a stable result is desired, use findFirst(DoublePredicate) instead.)

        Parameters:
        predicate - a non-interfering , stateless predicate which returned value should match
        Returns:
        an OptionalDouble describing some matching element of this stream, or an empty OptionalDouble if there's no matching element
        See Also:
        findAny(), findFirst(DoublePredicate)
      • indexOf

        public java.util.OptionalLong indexOf​(java.util.function.DoublePredicate predicate)
        Returns an OptionalLong describing the zero-based index of the first element of this stream, which matches given predicate, or an empty OptionalLong if there's no matching element.

        This is a short-circuiting terminal operation.

        Parameters:
        predicate - a non-interfering , stateless predicate which returned value should match
        Returns:
        an OptionalLong describing the index of the first matching element of this stream, or an empty OptionalLong if there's no matching element.
        Since:
        0.4.0
        See Also:
        findFirst(DoublePredicate)
      • boxed

        public StreamEx<java.lang.Double> boxed()
        Specified by:
        boxed in interface java.util.stream.DoubleStream
      • sequential

        public DoubleStreamEx sequential()
        Specified by:
        sequential in interface java.util.stream.BaseStream<java.lang.Double,​java.util.stream.DoubleStream>
        Specified by:
        sequential in interface java.util.stream.DoubleStream
        Overrides:
        sequential in class BaseStreamEx<java.lang.Double,​java.util.stream.DoubleStream,​java.util.Spliterator.OfDouble,​DoubleStreamEx>
      • parallel

        public DoubleStreamEx parallel()
        Description copied from class: BaseStreamEx

        If this stream was created using BaseStreamEx.parallel(ForkJoinPool), the new stream forgets about supplied custom ForkJoinPool and its terminal operation will be executed in common pool.

        Specified by:
        parallel in interface java.util.stream.BaseStream<java.lang.Double,​java.util.stream.DoubleStream>
        Specified by:
        parallel in interface java.util.stream.DoubleStream
        Overrides:
        parallel in class BaseStreamEx<java.lang.Double,​java.util.stream.DoubleStream,​java.util.Spliterator.OfDouble,​DoubleStreamEx>
      • parallel

        public DoubleStreamEx parallel​(java.util.concurrent.ForkJoinPool fjp)
        Description copied from class: BaseStreamEx
        Returns an equivalent stream that is parallel and bound to the supplied ForkJoinPool.

        This is an intermediate operation.

        The terminal operation of this stream or any derived stream (except the streams created via BaseStreamEx.parallel() or BaseStreamEx.sequential() methods) will be executed inside the supplied ForkJoinPool. If current thread does not belong to that pool, it will wait till calculation finishes.

        Overrides:
        parallel in class BaseStreamEx<java.lang.Double,​java.util.stream.DoubleStream,​java.util.Spliterator.OfDouble,​DoubleStreamEx>
        Parameters:
        fjp - a ForkJoinPool to submit the stream operation to.
        Returns:
        a parallel stream bound to the supplied ForkJoinPool
      • iterator

        public java.util.PrimitiveIterator.OfDouble iterator()
        Specified by:
        iterator in interface java.util.stream.BaseStream<java.lang.Double,​java.util.stream.DoubleStream>
        Specified by:
        iterator in interface java.util.stream.DoubleStream
      • append

        public DoubleStreamEx append​(double... values)
        Returns a new DoubleStreamEx which is a concatenation of this stream and the stream containing supplied values

        This is a quasi-intermediate operation.

        Parameters:
        values - the values to append to the stream
        Returns:
        the new stream
      • append

        public DoubleStreamEx append​(java.util.stream.DoubleStream other)
        Creates a lazily concatenated stream whose elements are all the elements of this stream followed by all the elements of the other stream. The resulting stream is ordered if both of the input streams are ordered, and parallel if either of the input streams is parallel. When the resulting stream is closed, the close handlers for both input streams are invoked.
        Parameters:
        other - the other stream
        Returns:
        this stream appended by the other stream
        See Also:
        DoubleStream.concat(DoubleStream, DoubleStream)
      • prepend

        public DoubleStreamEx prepend​(double... values)
        Returns a new DoubleStreamEx which is a concatenation of the stream containing supplied values and this stream

        This is a quasi-intermediate operation.

        Parameters:
        values - the values to prepend to the stream
        Returns:
        the new stream
      • prepend

        public DoubleStreamEx prepend​(java.util.stream.DoubleStream other)
        Creates a lazily concatenated stream whose elements are all the elements of the other stream followed by all the elements of this stream. The resulting stream is ordered if both of the input streams are ordered, and parallel if either of the input streams is parallel. When the resulting stream is closed, the close handlers for both input streams are invoked.
        Parameters:
        other - the other stream
        Returns:
        this stream prepended by the other stream
        See Also:
        DoubleStream.concat(DoubleStream, DoubleStream)
      • pairMap

        public DoubleStreamEx pairMap​(java.util.function.DoubleBinaryOperator mapper)
        Returns a stream consisting of the results of applying the given function to the every adjacent pair of elements of this stream.

        This is a quasi-intermediate operation.

        The output stream will contain one element less than this stream. If this stream contains zero or one element the output stream will be empty.

        Parameters:
        mapper - a non-interfering, stateless function to apply to each adjacent pair of this stream elements.
        Returns:
        the new stream
        Since:
        0.2.1
      • joining

        public java.lang.String joining​(java.lang.CharSequence delimiter)
        Returns a String which is the concatenation of the results of calling String.valueOf(double) on each element of this stream, separated by the specified delimiter, in encounter order.

        This is a terminal operation.

        Parameters:
        delimiter - the delimiter to be used between each element
        Returns:
        the result of concatenation. For empty input stream empty String is returned.
        Since:
        0.3.1
      • joining

        public java.lang.String joining​(java.lang.CharSequence delimiter,
                                        java.lang.CharSequence prefix,
                                        java.lang.CharSequence suffix)
        Returns a String which is the concatenation of the results of calling String.valueOf(double) on each element of this stream, separated by the specified delimiter, with the specified prefix and suffix in encounter order.

        This is a terminal operation.

        Parameters:
        delimiter - the delimiter to be used between each element
        prefix - the sequence of characters to be used at the beginning of the joined result
        suffix - the sequence of characters to be used at the end of the joined result
        Returns:
        the result of concatenation. For empty input stream prefix + suffix is returned.
        Since:
        0.3.1
      • takeWhile

        public DoubleStreamEx takeWhile​(java.util.function.DoublePredicate predicate)
        Returns a stream consisting of all elements from this stream until the first element which does not match the given predicate is found.

        This is a short-circuiting stateful operation. It can be either intermediate or quasi-intermediate. When using with JDK 1.9 or higher it calls the corresponding JDK 1.9 implementation. When using with JDK 1.8 it uses own implementation.

        While this operation is quite cheap for sequential stream, it can be quite expensive on parallel pipelines.

        Specified by:
        takeWhile in interface java.util.stream.DoubleStream
        Parameters:
        predicate - a non-interfering, stateless predicate to apply to elements.
        Returns:
        the new stream.
        Since:
        0.3.6
        See Also:
        takeWhileInclusive(DoublePredicate), dropWhile(DoublePredicate)
      • takeWhileInclusive

        public DoubleStreamEx takeWhileInclusive​(java.util.function.DoublePredicate predicate)
        Returns a stream consisting of all elements from this stream until the first element which does not match the given predicate is found (including the first mismatching element).

        This is a quasi-intermediate operation.

        While this operation is quite cheap for sequential stream, it can be quite expensive on parallel pipelines.

        Parameters:
        predicate - a non-interfering, stateless predicate to apply to elements.
        Returns:
        the new stream.
        Since:
        0.5.5
        See Also:
        takeWhile(DoublePredicate)
      • dropWhile

        public DoubleStreamEx dropWhile​(java.util.function.DoublePredicate predicate)
        Returns a stream consisting of all elements from this stream starting from the first element which does not match the given predicate. If the predicate is true for all stream elements, an empty stream is returned.

        This is a stateful operation. It can be either intermediate or quasi-intermediate. When using with JDK 1.9 or higher it calls the corresponding JDK 1.9 implementation. When using with JDK 1.8 it uses own implementation.

        While this operation is quite cheap for sequential stream, it can be quite expensive on parallel pipelines.

        Specified by:
        dropWhile in interface java.util.stream.DoubleStream
        Parameters:
        predicate - a non-interfering, stateless predicate to apply to elements.
        Returns:
        the new stream.
        Since:
        0.3.6
      • prefix

        public DoubleStreamEx prefix​(java.util.function.DoubleBinaryOperator op)
        Returns a stream containing cumulative results of applying the accumulation function going left to right.

        This is a stateful quasi-intermediate operation.

        This operation resembles scanLeft(DoubleBinaryOperator), but unlike scanLeft this operation is intermediate and accumulation function must be associative.

        This method cannot take all the advantages of parallel streams as it must process elements strictly left to right. Using an unordered source or removing the ordering constraint with unordered() may improve the parallel processing speed.

        Parameters:
        op - an associative , non-interfering , stateless function for computing the next element based on the previous one
        Returns:
        the new stream.
        Since:
        0.6.1
        See Also:
        scanLeft(DoubleBinaryOperator)
      • chain

        public <U> U chain​(java.util.function.Function<? super DoubleStreamEx,​U> mapper)
        Description copied from class: BaseStreamEx
        Applies the supplied function to this stream and returns the result of the function.

        This method can be used to add more functionality in the fluent style. For example, consider user-defined static method batches(stream, n) which breaks the stream into batches of given length. Normally you would write batches(StreamEx.of(input).map(...), 10).filter(...). Using the chain() method you can write in more fluent manner: StreamEx.of(input).map(...).chain(s -> batches(s, 10)).filter(...).

        You could even go further and define a method which returns a function like <T> UnaryOperator<StreamEx<T>> batches(int n) and use it like this: StreamEx.of(input).map(...).chain(batches(10)).filter(...).

        Specified by:
        chain in class BaseStreamEx<java.lang.Double,​java.util.stream.DoubleStream,​java.util.Spliterator.OfDouble,​DoubleStreamEx>
        Type Parameters:
        U - the type of the function result.
        Parameters:
        mapper - function to invoke.
        Returns:
        the result of the function invocation.
      • empty

        public static DoubleStreamEx empty()
        Returns an empty sequential DoubleStreamEx.
        Returns:
        an empty sequential stream
      • of

        public static DoubleStreamEx of​(double element)
        Returns a sequential DoubleStreamEx containing a single element.
        Parameters:
        element - the single element
        Returns:
        a singleton sequential stream
      • of

        public static DoubleStreamEx of​(double... elements)
        Returns a sequential ordered DoubleStreamEx whose elements are the specified values.
        Parameters:
        elements - the elements of the new stream
        Returns:
        the new stream
      • of

        public static DoubleStreamEx of​(double[] array,
                                        int startInclusive,
                                        int endExclusive)
        Returns a sequential DoubleStreamEx with the specified range of the specified array as its source.
        Parameters:
        array - the array, assumed to be unmodified during use
        startInclusive - the first index to cover, inclusive
        endExclusive - index immediately past the last index to cover
        Returns:
        an DoubleStreamEx for the array range
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if startInclusive is negative, endExclusive is less than startInclusive, or endExclusive is greater than the array size
        Since:
        0.1.1
        See Also:
        Arrays.stream(double[], int, int)
      • of

        public static DoubleStreamEx of​(java.lang.Double[] array)
        Returns a sequential ordered DoubleStreamEx whose elements are the unboxed elements of supplied array.
        Parameters:
        array - the array to create the stream from.
        Returns:
        the new stream
        Since:
        0.5.0
        See Also:
        Arrays.stream(Object[])
      • of

        public static DoubleStreamEx of​(java.nio.DoubleBuffer buf)
        Returns a sequential ordered DoubleStreamEx whose elements are the values in the supplied DoubleBuffer.

        The resulting stream covers only a portion of DoubleBuffer content which starts with position (inclusive) and ends with limit (exclusive). Changes in position and limit after the stream creation don't affect the stream.

        The resulting stream does not change the internal DoubleBuffer state.

        Parameters:
        buf - the DoubleBuffer to create a stream from
        Returns:
        the new stream
        Since:
        0.6.2
      • of

        public static DoubleStreamEx of​(float... elements)
        Returns a sequential ordered DoubleStreamEx whose elements are the specified float values casted to double.
        Parameters:
        elements - the elements of the new stream
        Returns:
        the new stream
        Since:
        0.2.0
      • of

        public static DoubleStreamEx of​(float[] array,
                                        int startInclusive,
                                        int endExclusive)
        Returns a sequential DoubleStreamEx with the specified range of the specified array as its source. Array values will be casted to double.
        Parameters:
        array - the array, assumed to be unmodified during use
        startInclusive - the first index to cover, inclusive
        endExclusive - index immediately past the last index to cover
        Returns:
        an IntStreamEx for the array range
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if startInclusive is negative, endExclusive is less than startInclusive, or endExclusive is greater than the array size
        Since:
        0.2.0
      • of

        public static DoubleStreamEx of​(java.util.stream.DoubleStream stream)
        Returns a DoubleStreamEx object which wraps given DoubleStream.

        The supplied stream must not be consumed or closed when this method is called. No operation must be performed on the supplied stream after it's wrapped.

        Parameters:
        stream - original stream
        Returns:
        the wrapped stream
        Since:
        0.0.8
      • of

        public static DoubleStreamEx of​(java.util.Spliterator.OfDouble spliterator)
        Returns a sequential DoubleStreamEx created from given Spliterator.OfDouble.
        Parameters:
        spliterator - a spliterator to create the stream from.
        Returns:
        the new stream
        Since:
        0.3.4
      • of

        public static DoubleStreamEx of​(java.util.PrimitiveIterator.OfDouble iterator)
        Returns a sequential, ordered DoubleStreamEx created from given PrimitiveIterator.OfDouble.

        This method is roughly equivalent to DoubleStreamEx.of(Spliterators.spliteratorUnknownSize(iterator, ORDERED)) , but may show better performance for parallel processing.

        Use this method only if you cannot provide better Stream source.

        Parameters:
        iterator - an iterator to create the stream from.
        Returns:
        the new stream
        Since:
        0.5.1
      • of

        public static DoubleStreamEx of​(java.util.OptionalDouble optional)
        Returns a sequential DoubleStreamEx containing an OptionalDouble value, if present, otherwise returns an empty DoubleStreamEx.
        Parameters:
        optional - the optional to create a stream of
        Returns:
        a stream with an OptionalDouble value if present, otherwise an empty stream
        Since:
        0.1.1
      • of

        public static DoubleStreamEx of​(java.util.Collection<java.lang.Double> collection)
        Returns a sequential ordered DoubleStreamEx whose elements are the unboxed elements of supplied collection.
        Parameters:
        collection - the collection to create the stream from.
        Returns:
        the new stream
        See Also:
        Collection.stream()
      • of

        public static DoubleStreamEx of​(java.util.Random random)
        Returns an effectively unlimited stream of pseudorandom double values, each between zero (inclusive) and one (exclusive) produced by given Random object.

        A pseudorandom double value is generated as if it's the result of calling the method Random.nextDouble().

        Parameters:
        random - a Random object to produce the stream from
        Returns:
        a stream of pseudorandom double values
        See Also:
        Random.doubles()
      • of

        public static DoubleStreamEx of​(java.util.Random random,
                                        long streamSize)
        Returns a stream producing the given streamSize number of pseudorandom double values, each between zero (inclusive) and one (exclusive) produced by given Random object.

        A pseudorandom double value is generated as if it's the result of calling the method Random.nextDouble().

        Parameters:
        random - a Random object to produce the stream from
        streamSize - the number of values to generate
        Returns:
        a stream of pseudorandom double values
        See Also:
        Random.doubles(long)
      • of

        public static DoubleStreamEx of​(java.util.Random random,
                                        double randomNumberOrigin,
                                        double randomNumberBound)
        Returns an effectively unlimited stream of pseudorandom double values, each conforming to the given origin (inclusive) and bound (exclusive) produced by given Random object.
        Parameters:
        random - a Random object to produce the stream from
        randomNumberOrigin - the origin (inclusive) of each random value
        randomNumberBound - the bound (exclusive) of each random value
        Returns:
        a stream of pseudorandom double values, each with the given origin (inclusive) and bound (exclusive)
        See Also:
        Random.doubles(double, double)
      • of

        public static DoubleStreamEx of​(java.util.Random random,
                                        long streamSize,
                                        double randomNumberOrigin,
                                        double randomNumberBound)
        Returns a stream producing the given streamSize number of pseudorandom double values, each conforming to the given origin (inclusive) and bound (exclusive) produced by given Random object.
        Parameters:
        random - a Random object to produce the stream from
        randomNumberOrigin - the origin (inclusive) of each random value
        randomNumberBound - the bound (exclusive) of each random value
        streamSize - the number of values to generate
        Returns:
        a stream of pseudorandom double values, each with the given origin (inclusive) and bound (exclusive)
        See Also:
        Random.doubles(long, double, double)
      • iterate

        public static DoubleStreamEx iterate​(double seed,
                                             java.util.function.DoubleUnaryOperator f)
        Returns an infinite sequential ordered DoubleStreamEx produced by iterative application of a function f to an initial element seed, producing a stream consisting of seed, f(seed), f(f(seed)), etc.

        The first element (position 0) in the DoubleStreamEx will be the provided seed. For n > 0, the element at position n, will be the result of applying the function f to the element at position n - 1.

        Parameters:
        seed - the initial element
        f - a function to be applied to to the previous element to produce a new element
        Returns:
        A new sequential DoubleStream
        See Also:
        iterate(double, DoublePredicate, DoubleUnaryOperator)
      • iterate

        public static DoubleStreamEx iterate​(double seed,
                                             java.util.function.DoublePredicate predicate,
                                             java.util.function.DoubleUnaryOperator f)
        Returns a sequential ordered DoubleStreamEx produced by iterative application of a function to an initial element, conditioned on satisfying the supplied predicate. The stream terminates as soon as the predicate function returns false.

        DoubleStreamEx.iterate should produce the same sequence of elements as produced by the corresponding for-loop:

        
             for (double index=seed; predicate.test(index); index = f.apply(index)) {
                 ... 
             }
         

        The resulting sequence may be empty if the predicate does not hold on the seed value. Otherwise the first element will be the supplied seed value, the next element (if present) will be the result of applying the function f to the seed value, and so on iteratively until the predicate indicates that the stream should terminate.

        Parameters:
        seed - the initial element
        predicate - a predicate to apply to elements to determine when the stream must terminate.
        f - a function to be applied to the previous element to produce a new element
        Returns:
        a new sequential DoubleStreamEx
        Since:
        0.6.0
        See Also:
        iterate(double, DoubleUnaryOperator)
      • generate

        public static DoubleStreamEx generate​(java.util.function.DoubleSupplier s)
        Returns an infinite sequential unordered stream where each element is generated by the provided DoubleSupplier. This is suitable for generating constant streams, streams of random elements, etc.
        Parameters:
        s - the DoubleSupplier for generated elements
        Returns:
        a new infinite sequential unordered DoubleStreamEx
        See Also:
        DoubleStream.generate(DoubleSupplier)
      • produce

        public static DoubleStreamEx produce​(java.util.function.Predicate<java.util.function.DoubleConsumer> producer)
        Return an ordered stream produced by consecutive calls of the supplied producer until it returns false.

        The producer function may call the passed consumer any number of times and return true if the producer should be called again or false otherwise. It's guaranteed that the producer will not be called anymore, once it returns false.

        This method is particularly useful when producer changes the mutable object which should be left in known state after the full stream consumption. Note however that if a short-circuiting operation is used, then the final state of the mutable object cannot be guaranteed.

        Parameters:
        producer - a predicate which calls the passed consumer to emit stream element(s) and returns true if it producer should be applied again.
        Returns:
        the new stream
        Since:
        0.6.0
      • constant

        public static DoubleStreamEx constant​(double value,
                                              long length)
        Returns a sequential unordered DoubleStreamEx of given length which elements are equal to supplied value.
        Parameters:
        value - the constant value
        length - the length of the stream
        Returns:
        a new DoubleStreamEx
        Since:
        0.1.2
      • zip

        public static DoubleStreamEx zip​(double[] first,
                                         double[] second,
                                         java.util.function.DoubleBinaryOperator mapper)
        Returns a sequential DoubleStreamEx containing the results of applying the given function to the corresponding pairs of values in given two arrays.
        Parameters:
        first - the first array
        second - the second array
        mapper - a non-interfering, stateless function to apply to each pair of the corresponding array elements.
        Returns:
        a new DoubleStreamEx
        Throws:
        java.lang.IllegalArgumentException - if length of the arrays differs.
        Since:
        0.2.1