Created
April 10, 2019 14:02
-
-
Save pgp/c5d028522dc6d25ebe42c0c332b7f62f to your computer and use it in GitHub Desktop.
Infinite dummy iterable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Iterator; | |
public class InfiniteIterable<T> implements Iterable { | |
private final T marker; | |
public InfiniteIterable(T marker) { | |
this.marker = marker; | |
} | |
@Override | |
public Iterator<T> iterator() { | |
return new Iterator<T>() { | |
@Override | |
public boolean hasNext() { | |
return true; | |
} | |
@Override | |
public T next() { | |
return marker; | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment