List of usage examples for java.util TreeSet TreeSet
public TreeSet()
From source file:Main.java
public static <T> Set<T> listToSet(Collection<T> list) { Set<T> set = new TreeSet<T>(); for (T t : list) set.add(t);// ww w . java 2s .co m return set; }
From source file:Main.java
public static <T> Set<T> toSet(final Iterable<T> iterable) { final Set<T> set = new TreeSet<T>(); for (Iterator<T> i = iterable.iterator(); i.hasNext();) { set.add(i.next());/*from www.j a va 2s. c o m*/ } return set; }
From source file:Main.java
public static <E> TreeSet<E> getTreeSet() { return new TreeSet<E>(); }
From source file:Main.java
public static <T> TreeSet<T> createTreeSet() { return new TreeSet<T>(); }
From source file:Main.java
public static Set<String> parseSeparetedStringSet(String inputString, String delim) { Set<String> ret = new TreeSet<String>(); String[] data = inputString.split(delim); for (String d : data) { ret.add(d.trim());// w w w . j a va 2s. co m } return ret; }
From source file:Main.java
public static Set<Integer> getNumsFromStr(String text) { text = null == text ? "" : text; String[] ary = text.replaceAll("[^\\d]", " ").split("\\s+"); Set<Integer> set = new TreeSet<Integer>(); for (String num : ary) { if (!num.trim().equals("")) { set.add(Integer.valueOf(num.trim())); }/*w w w.ja v a 2 s .co m*/ } return set; }
From source file:Main.java
public static <K, V> Set<V> valueToTreeSet(Map<K, V> map) { if (isNotNull(map)) { Set<V> set = new TreeSet<>(); for (V v : map.values()) { System.out.println(v.hashCode()); System.out.println(set.contains(v)); set.add(v);/*ww w. j ava 2s . c o m*/ } return set; } return null; }
From source file:Main.java
public static <T> Set<T> getSortedIntersectionValues(Collection<T> colection1, Collection<T> colection2) { Set<T> set = new TreeSet<>(); set.addAll(getIntersectionValues(colection1, colection2)); return set;// w w w. j av a 2s .co m }
From source file:Main.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);/* ww w .j ava 2s.c o m*/ return tmp; }
From source file:Main.java
public static <K, V extends Comparable<V>> void addToValueSortedSet(Map<K, SortedSet<V>> map, K key, V value) { SortedSet<V> values = map.get(key); if (values == null) { values = new TreeSet<V>(); map.put(key, values);//from w ww.ja v a 2 s . c o m } values.add(value); }