Java Utililty Methods Iterator to Iterable

List of utility methods to do Iterator to Iterable

Description

The list of methods to do Iterator to Iterable are organized into topic(s).

Method

Iterableiterable(final Iterator it)
iterable
return new Iterable<A>() {
    boolean used = false;
    @Override
    public Iterator<A> iterator() {
        if (used)
            throw new IllegalStateException("iterator may not be called more than once");
        used = true;
        return it;
...
Iterableiterable(final Iterator iterator)
iterable
if (iterator == null) {
    throw new NullPointerException();
return new Iterable<E>() {
    public Iterator<E> iterator() {
        return iterator;
};
...
Iterableiterable(final Iterator iterator)
Makes an Interator iterable with foreach
return new Iterable<I>() {
    @Override
    public Iterator<I> iterator() {
        return iterator;
};
Iterableiterable(final Iterator iter)
Creates an Iterable instance that just returns the given Iterator from its iterator() method.
if (iter == null)
    throw new NullPointerException("iter parameter is null"); 
return new Iterable<T>() {
    public Iterator<T> iterator() {
        return iter;
};
Iterableiterable(Iterator iterator)
iterable
return () -> iterator;
IterabletoIterable(final Iterator iterator)
Returns an Iterable returning the passed in Iterator .
return new Iterable<T>() {
    @Override
    public Iterator<T> iterator() {
        return iterator;
};
IterabletoIterable(final Iterator iterator)
to Iterable
return new Iterable<T>() {
    @Override
    public Iterator<T> iterator() {
        return iterator;
};
IterabletoIterable(final Iterator iterator)
Create an Iterable from an Iterator .
return () -> iterator;