Skip to content

Instantly share code, notes, and snippets.

@pgp
Created April 10, 2019 14:02
Show Gist options
  • Save pgp/c5d028522dc6d25ebe42c0c332b7f62f to your computer and use it in GitHub Desktop.
Save pgp/c5d028522dc6d25ebe42c0c332b7f62f to your computer and use it in GitHub Desktop.
Infinite dummy iterable
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