class Sets {

    public static <V> NavigableSet<V> sortedSet( Iterator<V> iterator ) {
        NavigableSet<V> set = new TreeSet<>();
        while ( iterator.hasNext() ) {
            set.add( iterator.next() );
        }
        return set;
    }

}