Add missing forEach to TIterable

This commit is contained in:
Dylan 2019-04-01 17:24:01 -04:00 committed by Alexey Andreev
parent a9c4ab6aa4
commit d18d50a823

View File

@ -22,6 +22,12 @@ import org.teavm.classlib.java.util.TSpliterator;
public interface TIterable<T> { public interface TIterable<T> {
TIterator<T> iterator(); TIterator<T> iterator();
default void forEach(Consumer<? super T> action) {
for (TIterator<T> itr = iterator(); itr.hasNext();) {
action.accept(itr.next());
}
}
default TSpliterator<T> spliterator() { default TSpliterator<T> spliterator() {
TIterator<T> iterator = iterator(); TIterator<T> iterator = iterator();
return new TSpliterator<T>() { return new TSpliterator<T>() {