Example usage for java.util TreeSet TreeSet

List of usage examples for java.util TreeSet TreeSet

Introduction

In this page you can find the example usage for java.util TreeSet TreeSet.

Prototype

public TreeSet() 

Source Link

Document

Constructs a new, empty tree set, sorted according to the natural ordering of its elements.

Usage

From source file:com.spotify.echoprintserver.nativelib.Util.java

public static List<Integer> sortedDistinct(List<Integer> seq) {
    Set<Integer> codeSet = new TreeSet<Integer>();
    codeSet.addAll(seq);/*  w  ww  .  ja  v  a 2s  .c  om*/
    List<Integer> uniqueSortedCodeSet = new ArrayList<Integer>();
    uniqueSortedCodeSet.addAll(codeSet);
    Collections.sort(uniqueSortedCodeSet);
    return uniqueSortedCodeSet;
}

From source file:com.thoughtworks.go.apiv4.agents.representers.UpdateRequestRepresenter.java

static String toCommaSeparatedString(JsonArray jsonArray) {
    if (jsonArray == null) {
        return null;
    }//from ww w.j ava2s  .c om
    final Set<String> list = new TreeSet<>();
    for (JsonElement jsonElement : jsonArray) {
        list.add(jsonElement.getAsString());
    }
    return String.join(",", list);
}

From source file:TwitterClustering.java

public static <T> Set<T> intersection(Set<T> setA, Set<T> setB) {
    Set<T> tmp = new TreeSet<T>();
    for (T x : setA) {
        if (setB.contains(x)) {
            tmp.add(x);/*from  w  w  w .j  ava 2  s.c  o  m*/
        }
    }
    return tmp;
}

From source file:Main.java

private SortedSet<Integer> getSet(String str) {
    SortedSet<Integer> result = new TreeSet<Integer>();
    StringTokenizer st = new StringTokenizer(str, " ");
    while (st.hasMoreTokens()) {
        result.add(Integer.valueOf(st.nextToken()));
    }// w  w w  .  j  av a 2  s.c  o  m
    return result;
}

From source file:de.tudarmstadt.ukp.dkpro.spelling.experiments.data.CreateVocabularyFromCorpus.java

private static void createVocabulary(Corpus corpus) throws Exception {
    Set<String> vocabulary = new TreeSet<String>();
    for (String token : corpus.getTokens()) {
        vocabulary.add(token);/*from w ww.java  2  s. com*/
    }

    StringBuilder sb = new StringBuilder();
    for (String item : vocabulary) {
        sb.append(item);
        sb.append(System.getProperty("line.separator"));
    }

    FileUtils.writeStringToFile(new File("target/" + corpus.getName() + ".txt"), sb.toString());
}

From source file:TreeHeap.java

/** 
 * Creates a new tree heap.
 */
public TreeHeap() {
    tree = new TreeSet();
}

From source file:com.glaf.core.util.AnnotationUtils.java

public static Collection<String> findClasses(String name) {
    AnnotationDB db = getAnnotationDB();
    Map<String, Set<String>> annotationIndex = db.getAnnotationIndex();
    Set<String> entities = annotationIndex.get(name);
    Collection<String> sortSet = new TreeSet<String>();
    if (entities != null && !entities.isEmpty()) {
        for (String str : entities) {
            sortSet.add(str);/*from  ww w . j a  v a  2 s .c  o  m*/
        }
    }
    return sortSet;
}

From source file:com.vrem.wifianalyzer.wifi.model.Security.java

public static List<Security> findAll(String capabilities) {
    Set<Security> results = new TreeSet<>();
    if (capabilities != null) {
        String[] values = capabilities.toUpperCase().replace("][", "-").replace("]", "").replace("[", "")
                .split("-");
        for (String value : values) {
            try {
                results.add(Security.valueOf(value));
            } catch (Exception e) {
                // skip getCapabilities that are not getSecurity
            }/*from w  w  w.  j av  a2s  . c o  m*/
        }
    }
    return new ArrayList<>(results);
}

From source file:com.intuit.karate.http.apache.LoggingUtils.java

private static Collection<String> sortKeys(Header[] headers) {
    Set<String> keys = new TreeSet<>();
    for (Header header : headers) {
        keys.add(header.getName());// ww  w. j a  va2  s.co m
    }
    return keys;
}

From source file:apriori.ItemSet.java

public ItemSet() {
    _sortedItems = new TreeSet<>();
    _items = new ArrayList<>();
    _support = 0;
}