/** * Returns a {@link DoubleStreamEx} consisting of the elements of given * array corresponding to the indices which appear in this stream. * * <p> * This is an intermediate operation. * * @param array the array to take the elements from * @return the new stream * @since 0.1.2 */ public DoubleStreamEx elements(double[] array) { return mapToDouble(idx -> array[idx]); }
/** * Returns a sequential ordered {@code DoubleStreamEx} whose elements are * the values in the supplied {@link java.nio.DoubleBuffer}. * * <p> * The resulting stream covers only a portion of {@code DoubleBuffer} * content which starts with {@linkplain Buffer#position() position} * (inclusive) and ends with {@linkplain Buffer#limit() limit} (exclusive). * Changes in position and limit after the stream creation don't affect the * stream. * * <p> * The resulting stream does not change the internal {@code DoubleBuffer} * state. * * @param buf the {@code DoubleBuffer} to create a stream from * @return the new stream * @since 0.6.2 */ public static DoubleStreamEx of(java.nio.DoubleBuffer buf) { return IntStreamEx.range(buf.position(), buf.limit()).mapToDouble(buf::get); }