Skip to content

Commit 77e2391

Browse files
committed
Merge branch 'replace-iterator-with-tryadvance' into development
2 parents 124bc9d + e3db7b5 commit 77e2391

File tree

113 files changed

+2545
-2867
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+2545
-2867
lines changed

src/main/java/org/jayield/Advancer.java

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,20 @@
1616

1717
package org.jayield;
1818

19-
import java.util.Iterator;
20-
import java.util.NoSuchElementException;
21-
2219
/**
23-
* Sequential traverser with both internal and external iteration approach.
20+
* Sequential traverser with internal and individually step approach.
2421
*/
25-
public interface Advancer<T> extends Iterator<T>, Traverser<T> {
22+
public interface Advancer<T> {
23+
/**
24+
* If a remaining element exists, yields that element through
25+
* the given action.
26+
*/
27+
boolean tryAdvance(Yield<? super T> yield);
28+
2629
/**
2730
* An Advancer object without elements.
2831
*/
2932
static <R> Advancer<R> empty() {
30-
return new Advancer<R>() {
31-
@Override
32-
public boolean hasNext() {
33-
return false;
34-
}
35-
36-
@Override
37-
public R next() {
38-
throw new NoSuchElementException("No such elements available for iteration!");
39-
}
40-
41-
@Override
42-
public void traverse(Yield<? super R> yield) {
43-
/* Do nothing. Since there are no elements, thus there is nothing to do. */
44-
}
45-
};
33+
return action -> false;
4634
}
47-
48-
4935
}

0 commit comments

Comments
 (0)