11package fj .data ;
22
33import static fj .data .Option .some ;
4+ import static fj .data .Stream .fromIterable ;
45import static fj .data .Stream .iterableStream ;
56import fj .Equal ;
67import fj .F ;
@@ -85,7 +86,7 @@ public static <A, B> F<F<A, B>, F<A, IterableW<B>>> arrow() {
8586 * @return an iterable result of binding the given function over the wrapped Iterable.
8687 */
8788 public <B , T extends Iterable <B >> IterableW <B > bind (final F <A , T > f ) {
88- return wrap (iterableStream (this ).bind (a -> iterableStream (f .f (a ))));
89+ return wrap (fromIterable (this ).bind (a -> fromIterable (f .f (a ))));
8990 }
9091
9192 /**
@@ -128,12 +129,12 @@ public static <A, B, C> F<Iterable<A>, F<Iterable<B>, IterableW<C>>> liftM2(fina
128129 * @return A iterable of iterables containing the results of the bind operations across all given iterables.
129130 */
130131 public static <A , T extends Iterable <A >> IterableW <IterableW <A >> sequence (final Iterable <T > as ) {
131- final Stream <T > ts = iterableStream (as );
132+ final Stream <T > ts = fromIterable (as );
132133 return ts .isEmpty () ?
133134 iterable (wrap (Option .<A >none ())) :
134135 wrap (ts .head ()).bind (a ->
135136 sequence (ts .tail ().map (IterableW .<T , Stream <T >>wrap ())._1 ()).bind (as2 ->
136- iterable (wrap (Stream .cons (a , () -> iterableStream (as2 ))))
137+ iterable (wrap (Stream .cons (a , () -> fromIterable (as2 ))))
137138 )
138139 );
139140 }
@@ -221,7 +222,7 @@ public A foldLeft1(final F2<A, A, A> f) {
221222 * @return The final result after the left-fold reduction.
222223 */
223224 public A foldLeft1 (final F <A , F <A , A >> f ) {
224- return iterableStream (this ).foldLeft1 (f );
225+ return fromIterable (this ).foldLeft1 (f );
225226 }
226227
227228 /**
@@ -254,7 +255,7 @@ public Iterator<A> iterator() {
254255 * @return A new iterable with the results of applying the functions to this iterable.
255256 */
256257 public <B > IterableW <B > zapp (final Iterable <F <A , B >> fs ) {
257- return wrap (iterableStream (this ).zapp (iterableStream (fs )));
258+ return wrap (fromIterable (this ).zapp (fromIterable (fs )));
258259 }
259260
260261 /**
@@ -268,7 +269,7 @@ public <B> IterableW<B> zapp(final Iterable<F<A, B>> fs) {
268269 * iterable.
269270 */
270271 public <B , C > Iterable <C > zipWith (final Iterable <B > bs , final F <A , F <B , C >> f ) {
271- return wrap (iterableStream (this ).zipWith (iterableStream (bs ), f ));
272+ return wrap (fromIterable (this ).zipWith (fromIterable (bs ), f ));
272273 }
273274
274275 /**
@@ -295,7 +296,7 @@ public <B, C> Iterable<C> zipWith(final Iterable<B> bs, final F2<A, B, C> f) {
295296 * iterable.
296297 */
297298 public <B > Iterable <P2 <A , B >> zip (final Iterable <B > bs ) {
298- return wrap (iterableStream (this ).zip (iterableStream (bs )));
299+ return wrap (fromIterable (this ).zip (fromIterable (bs )));
299300 }
300301
301302 /**
@@ -304,7 +305,7 @@ public <B> Iterable<P2<A, B>> zip(final Iterable<B> bs) {
304305 * @return A new iterable with the same length as this iterable.
305306 */
306307 public Iterable <P2 <A , Integer >> zipIndex () {
307- return wrap (iterableStream (this ).zipIndex ());
308+ return wrap (fromIterable (this ).zipIndex ());
308309 }
309310
310311 /**
@@ -317,29 +318,29 @@ public List<A> toStandardList() {
317318 return new List <A >() {
318319
319320 public int size () {
320- return iterableStream (IterableW .this ).length ();
321+ return fromIterable (IterableW .this ).length ();
321322 }
322323
323324 public boolean isEmpty () {
324- return iterableStream (IterableW .this ).isEmpty ();
325+ return fromIterable (IterableW .this ).isEmpty ();
325326 }
326327
327328 @ SuppressWarnings ({"unchecked" })
328329 public boolean contains (final Object o ) {
329- return iterableStream (IterableW .this ).exists (Equal .<A >anyEqual ().eq ((A ) o ));
330+ return fromIterable (IterableW .this ).exists (Equal .<A >anyEqual ().eq ((A ) o ));
330331 }
331332
332333 public Iterator <A > iterator () {
333334 return IterableW .this .iterator ();
334335 }
335336
336337 public Object [] toArray () {
337- return Array .iterableArray (iterableStream (IterableW .this )).array ();
338+ return Array .iterableArray (fromIterable (IterableW .this )).array ();
338339 }
339340
340341 @ SuppressWarnings ({"SuspiciousToArrayCall" })
341342 public <T > T [] toArray (final T [] a ) {
342- return iterableStream (IterableW .this ).toCollection ().toArray (a );
343+ return fromIterable (IterableW .this ).toCollection ().toArray (a );
343344 }
344345
345346 public boolean add (final A a ) {
@@ -351,7 +352,7 @@ public boolean remove(final Object o) {
351352 }
352353
353354 public boolean containsAll (final Collection <?> c ) {
354- return iterableStream (IterableW .this ).toCollection ().containsAll (c );
355+ return fromIterable (IterableW .this ).toCollection ().containsAll (c );
355356 }
356357
357358 public boolean addAll (final Collection <? extends A > c ) {
@@ -375,7 +376,7 @@ public void clear() {
375376 }
376377
377378 public A get (final int index ) {
378- return iterableStream (IterableW .this ).index (index );
379+ return fromIterable (IterableW .this ).index (index );
379380 }
380381
381382 public A set (final int index , final A element ) {
@@ -420,7 +421,7 @@ public ListIterator<A> listIterator(final int index) {
420421 }
421422
422423 public List <A > subList (final int fromIndex , final int toIndex ) {
423- return wrap (Stream .iterableStream (IterableW .this ).drop (fromIndex ).take (toIndex - fromIndex )).toStandardList ();
424+ return wrap (Stream .fromIterable (IterableW .this ).drop (fromIndex ).take (toIndex - fromIndex )).toStandardList ();
424425 }
425426
426427 private ListIterator <A > toListIterator (final Option <Zipper <A >> z ) {
@@ -476,6 +477,6 @@ public void add(final A a) {
476477 }
477478
478479 public Option <Zipper <A >> toZipper () {
479- return Zipper .fromStream (iterableStream (this ));
480+ return Zipper .fromStream (fromIterable (this ));
480481 }
481482}
0 commit comments