Java Collection Convert toTreeSet(Collection collection, Comparator comparator)

Here you can find the source of toTreeSet(Collection collection, Comparator comparator)

Description

to Tree Set

License

Apache License

Declaration

public static <T> TreeSet<T> toTreeSet(Collection<T> collection, Comparator<T> comparator) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {

    public static <T> TreeSet<T> toTreeSet(Collection<T> collection, Comparator<T> comparator) {
        final TreeSet<T> treeSet = new TreeSet<T>(comparator);
        for (T t : collection) {
            treeSet.add(t);/*from w  w w . ja v  a  2 s.  c  om*/
        }
        return treeSet;
    }
}

Related

  1. toStringBuilder( Collection collection, String delimiter)
  2. toStringColl(Collection set)
  3. toSV(Collection collection, String separator)
  4. toTestParameters(Collection rawParams)
  5. toToolTip(final Collection collection)
  6. toUnmodifiableCollection( AnyCollection collection)
  7. trimCollection(Collection collectionToBeConverted)