Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Iterator;

import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
    /**
     * 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;
    }
}