Java Iterator toSet(Iterator iteration)

Here you can find the source of toSet(Iterator iteration)

Description

to Set

License

Open Source License

Declaration

public static <T> Set<T> toSet(Iterator<? extends T> iteration) 

Method Source Code


//package com.java2s;
import java.util.*;

public class Main {
    public static <T> Set<T> toSet(Iterator<? extends T> iteration) {
        Set<T> elements = new HashSet<T>(1);
        while (iteration.hasNext()) {
            elements.add(iteration.next());
        }/*from w w  w. ja  va  2 s .c om*/
        return elements;
    }
}

Related

  1. toCommaSeparatedString(Iterator i)
  2. toIterator(Collection col)
  3. toIterator(final T[] data)
  4. toMap(final Iterator> iterator)
  5. toObjectIterator(Object[] objects)
  6. toString(Iterator iterObjects)
  7. toString(Iterator tokens)
  8. toStringArray(Iterator iterator)
  9. unwrapIterator(Iterator iter)