/** * Returns a stream projection of this array. * * @return A stream projection of this array. */ @SuppressWarnings("unchecked") public Stream<A> toStream() { return Stream.unfold( new F<Integer, Option<P2<A, Integer>>>() { public Option<P2<A, Integer>> f(final Integer o) { return a.length > o ? some(p((A) a[o], o + 1)) : Option.<P2<A, Integer>>none(); } }, 0); }