From 699c2890ca50f9b33ee8e228e544105754b0daca Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Fri, 17 Feb 2017 02:19:59 -0500 Subject: IList is now iterable. No more useless toIterable()s :) --- BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java index f920fce..f6b207a 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java @@ -1,6 +1,7 @@ package bjc.utils.funcdata; import java.util.Comparator; +import java.util.Iterator; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -18,7 +19,7 @@ import bjc.utils.data.IPair; * @param * The type in this list */ -public interface IList { +public interface IList extends Iterable { /** * Add an item to this list * @@ -72,7 +73,7 @@ public interface IList { * The collector to use for reduction * @return The reduced list */ - public default ReducedType collect( + default ReducedType collect( Collector collector) { BiConsumer accumulator = collector.accumulator(); @@ -147,7 +148,7 @@ public interface IList { * @param action * The action to apply to each member of the list. */ - void forEach(Consumer action); + void forEach(Consumer action); /** * Apply a given function to each element in the list and its index. @@ -334,7 +335,7 @@ public interface IList { * * @return The list without the first element */ - public IList tail(); + IList tail(); /** * Convert this list into an array @@ -343,12 +344,17 @@ public interface IList { * The type of array to return * @return The list, as an array */ - public ContainedType[] toArray(ContainedType[] type); + ContainedType[] toArray(ContainedType[] type); /** * Convert the list into a Iterable * * @return An iterable view onto the list */ - public Iterable toIterable(); + Iterable toIterable(); + + @Override + default Iterator iterator() { + return toIterable().iterator(); + } } -- cgit v1.2.3