/** * Returns a sequential ordered {@code DoubleStreamEx} whose elements are * the unboxed elements of supplied array. * * @param array the array to create the stream from. * @return the new stream * @see Arrays#stream(Object[]) * @since 0.5.0 */ public static DoubleStreamEx of(Double[] array) { return seq(Arrays.stream(array).mapToDouble(Double::doubleValue)); }
/** * Returns a sequential ordered {@code DoubleStreamEx} whose elements are * the unboxed elements of supplied collection. * * @param collection the collection to create the stream from. * @return the new stream * @see Collection#stream() */ public static DoubleStreamEx of(Collection<Double> collection) { return seq(collection.stream().mapToDouble(Double::doubleValue)); }
/** * Returns an infinite sequential unordered stream where each element is * generated by the provided {@code DoubleSupplier}. This is suitable for * generating constant streams, streams of random elements, etc. * * @param s the {@code DoubleSupplier} for generated elements * @return a new infinite sequential unordered {@code DoubleStreamEx} * @see DoubleStream#generate(DoubleSupplier) */ public static DoubleStreamEx generate(DoubleSupplier s) { return seq(DoubleStream.generate(s)); }
/** * Returns an effectively unlimited stream of pseudorandom {@code double} * values, each conforming to the given origin (inclusive) and bound * (exclusive) produced by given {@link Random} object. * * @param random a {@link Random} object to produce the stream from * @param randomNumberOrigin the origin (inclusive) of each random value * @param randomNumberBound the bound (exclusive) of each random value * @return a stream of pseudorandom {@code double} values, each with the * given origin (inclusive) and bound (exclusive) * @see Random#doubles(double, double) */ public static DoubleStreamEx of(Random random, double randomNumberOrigin, double randomNumberBound) { return seq(random.doubles(randomNumberOrigin, randomNumberBound)); }
/** * Returns a stream producing the given {@code streamSize} number of * pseudorandom {@code double} values, each between zero (inclusive) and one * (exclusive) produced by given {@link Random} object. * * <p> * A pseudorandom {@code double} value is generated as if it's the result of * calling the method {@link Random#nextDouble()}. * * @param random a {@link Random} object to produce the stream from * @param streamSize the number of values to generate * @return a stream of pseudorandom {@code double} values * @see Random#doubles(long) */ public static DoubleStreamEx of(Random random, long streamSize) { return seq(random.doubles(streamSize)); }
/** * Returns an effectively unlimited stream of pseudorandom {@code double} * values, each between zero (inclusive) and one (exclusive) produced by * given {@link Random} object. * * <p> * A pseudorandom {@code double} value is generated as if it's the result of * calling the method {@link Random#nextDouble()}. * * @param random a {@link Random} object to produce the stream from * @return a stream of pseudorandom {@code double} values * @see Random#doubles() */ public static DoubleStreamEx of(Random random) { return seq(random.doubles()); }
/** * Returns a stream producing the given {@code streamSize} number of * pseudorandom {@code double} values, each conforming to the given origin * (inclusive) and bound (exclusive) produced by given {@link Random} * object. * * @param random a {@link Random} object to produce the stream from * @param randomNumberOrigin the origin (inclusive) of each random value * @param randomNumberBound the bound (exclusive) of each random value * @param streamSize the number of values to generate * @return a stream of pseudorandom {@code double} values, each with the * given origin (inclusive) and bound (exclusive) * @see Random#doubles(long, double, double) */ public static DoubleStreamEx of(Random random, long streamSize, double randomNumberOrigin, double randomNumberBound) { return seq(random.doubles(streamSize, randomNumberOrigin, randomNumberBound)); }