From 6c595e7f035e583cae2a5a443a0a4871d160612d Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 21 Jul 2015 15:04:57 +0300 Subject: [PATCH] Fix #4. Custom Iterator for list. --- src/com/annimon/stream/Stream.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/com/annimon/stream/Stream.java b/src/com/annimon/stream/Stream.java index 2fae9c4a..5e84d79a 100644 --- a/src/com/annimon/stream/Stream.java +++ b/src/com/annimon/stream/Stream.java @@ -17,6 +17,23 @@ */ public class Stream { + public static Stream of(final List list) { + return new Stream(new Iterator() { + + private int index = 0; + + @Override + public boolean hasNext() { + return index < list.size(); + } + + @Override + public T next() { + return list.get(index++); + } + }); + } + public static Stream of(Iterator iterator) { return new Stream(iterator); }