/** * Returns an {@link IntStreamEx} 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 IntStreamEx elements(int[] array) { return map(idx -> array[idx]); }
/** * Returns a sequential ordered {@code IntStreamEx} whose elements are the * values in the supplied {@link java.nio.IntBuffer}. * * <p> * The resulting stream covers only a portion of {@code IntBuffer} 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 IntBuffer} * state. * * @param buf the {@code IntBuffer} to create a stream from * @return the new stream * @since 0.6.2 */ public static IntStreamEx of(java.nio.IntBuffer buf) { return range(buf.position(), buf.limit()).map(buf::get); }