Here you can find the source of sortedSetFromIterator(Iterator
Parameter | Description |
---|---|
i | an iterator to pull elements from |
T | < > The type of the elements |
public static <T> SortedSet<T> sortedSetFromIterator(Iterator<T> i)
//package com.java2s; import java.util.Iterator; import java.util.SortedSet; import java.util.TreeSet; public class Main { /**/* w ww . j a v a 2 s .com*/ * Constructs a SortedSet<T> with all the elements available from i * @param i an iterator to pull elements from * @param <T> The type of the elements * @return a SortedSet of the elements */ public static <T> SortedSet<T> sortedSetFromIterator(Iterator<T> i) { SortedSet<T> retval = new TreeSet<T>(); while (i.hasNext()) retval.add(i.next()); return retval; } }