Java Iterator to Iterable toIterable(final Iterator iterator)

Here you can find the source of toIterable(final Iterator iterator)

Description

Create an Iterable from an Iterator .

License

Open Source License

Parameter

Parameter Description
iterator the iterator
T the type

Return

the iterable

Declaration

public static <T> Iterable<T> toIterable(final Iterator<T> iterator) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Iterator;

public class Main {
    /**// w ww  . j a v a 2  s .c  o  m
     * Create an {@link Iterable} from an {@link Iterator}.
     *
     * @param iterator
     *            the iterator
     * @param <T>
     *            the type
     * @return the iterable
     */
    public static <T> Iterable<T> toIterable(final Iterator<T> iterator) {
        return () -> iterator;
    }
}

Related

  1. iterable(final Iterator iterator)
  2. iterable(final Iterator iter)
  3. iterable(Iterator iterator)
  4. toIterable(final Iterator iterator)
  5. toIterable(final Iterator iterator)