List of usage examples for java.util TreeSet TreeSet
public TreeSet(SortedSet<E> s)
From source file:Main.java
/** * Return serializable data, the format of these data is placed like the following format * ${key}=${value}/*from www . j av a 2s. c om*/ * * @param properties Properties instance * @return serializable data * @throws java.io.UnsupportedEncodingException * if errors occure during text converted to UTF-8 encoding */ public static byte[] getSerializablePropertiesData(Properties properties) throws UnsupportedEncodingException { Set keySet = properties.keySet(); TreeSet keys = new TreeSet(keySet); Iterator it = keys.iterator(); StringBuffer bf = new StringBuffer(); while (it.hasNext()) { String item = (String) it.next(); String resourceValue = (String) properties.get(item); bf.append(item); bf.append("="); bf.append(resourceValue); bf.append("\n"); } return bf.toString().getBytes("UTF-8"); }
From source file:Main.java
public static <E> TreeSet<E> newTreeSet(final SortedSet<? extends E> s) { return new TreeSet<E>(s); }
From source file:DataSet.java
public DataSet(final String name, final Integer... seasons) { this.name = name; this.data = Collections.unmodifiableSet(new TreeSet<>(Arrays.asList(seasons))); }
From source file:Main.java
/** * Creates a case-insensitive set./*w w w. j av a 2 s . c om*/ * * @return An empty case-insensitive set */ public static SortedSet<String> newCaseInsensitiveSet() { TreeSet<String> rv = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); return rv; }
From source file:TwitterClustering.java
/** * @param args/*from w ww . j a va 2s .com*/ * the command line arguments */ public static <T> Set<T> union(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>(setA); tmp.addAll(setB); return tmp; }
From source file:Main.java
public TreeSetDesc() { comparator = new SetComparator(); set = new TreeSet<String>(comparator); }
From source file:Main.java
/** * Returns an immutable Serializable Set containing the values. * @param <T> T//from w w w . j ava 2 s .c o m * @param values Collection<T> * @return Set<T> */ public static <T> Set<T> unmodifiableSet(Collection<T> values) { TreeSet<T> set = new TreeSet<T>(values); return Collections.unmodifiableSet(set); }
From source file:cn.edu.zjnu.acm.judge.mapper.BestSubmissionsBuilder.java
public static String bestSubmissions(@Param("problemId") long problemId, @Param("pageable") Pageable pageable) { Set<String> dejaVu = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); Sort sort = Optional.ofNullable(pageable.getSort()).map(s -> s.and(DEFAULT_SORT)).orElse(DEFAULT_SORT); Sort.Order[] orders = StreamSupport.stream(sort.spliterator(), false) .filter(order -> ALLOW_COLUMNS.contains(order.getProperty()) && dejaVu.add(order.getProperty())) .toArray(Sort.Order[]::new); final int length = orders.length; log.debug("{}", Arrays.asList(orders)); StringBuilder sb = new StringBuilder( "select " + SubmissionMapper.LIST_COLUMNS + " from solution s where problem_id=").append(problemId) .append(" and score=100 "); for (int i = length - 1; i >= 0; --i) { sb.append("and(user_id"); for (int j = 0; j <= i; ++j) { sb.append(',').append(orders[j].getProperty()); }// w w w. j a va2s . co m sb.append(")in(select user_id"); for (int j = 0; j < i; ++j) { sb.append(',').append(orders[j].getProperty()); } sb.append(',').append(orders[i].isAscending() ? "min" : "max").append("(") .append(orders[i].getProperty()).append(")").append(orders[i].getProperty()) .append(" from solution where problem_id=").append(problemId).append(" and score=100 "); } for (int i = 0; i < length; ++i) { sb.append("group by user_id)"); } if (length > 0) { sb.append(" order by "); for (int i = 0; i < length; ++i) { if (i > 0) { sb.append(","); } sb.append(orders[i].getProperty()); if (!orders[i].isAscending()) { sb.append(" desc"); } } } return sb.append(" limit ").append(pageable.getOffset()).append(",").append(pageable.getPageSize()) .toString(); }
From source file:de.hasait.clap.impl.AbstractCLAPNode.java
protected static final void addHelpNode(final Map<CLAPHelpCategoryImpl, Set<CLAPHelpNode>> pOptionNodes, final CLAPHelpCategoryImpl pCurrentCategory, final CLAPHelpNode pNode) { final CLAPHelpCategoryImpl currentCategory = pNode.getHelpCategory() != null ? pNode.getHelpCategory() : pCurrentCategory;// w ww . ja va2s . com if (!pOptionNodes.containsKey(currentCategory)) { pOptionNodes.put(currentCategory, new TreeSet<CLAPHelpNode>(new Comparator<CLAPHelpNode>() { @Override public int compare(final CLAPHelpNode pO1, final CLAPHelpNode pO2) { return pO1.getHelpID().compareTo(pO2.getHelpID()); } })); } pOptionNodes.get(currentCategory).add(pNode); }
From source file:com.ebay.erl.mobius.core.JobSetup.java
/** * specify the columns that a mapper needs to emit. *///from w w w. j ava 2 s . c o m public static void setupProjections(JobConf job, Dataset dataset, byte datasetID, Column... projections) { StringBuffer sortedColumns = new StringBuffer(); // dedupe the projection input column name and then sort it. Set<String> uniqueColumnNames = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (Column aProjection : projections) { uniqueColumnNames.add(aProjection.getInputColumnName()); } Iterator<String> it = uniqueColumnNames.iterator(); while (it.hasNext()) { sortedColumns.append(it.next()); if (it.hasNext()) sortedColumns.append(","); } job.set(datasetID + ".value.columns", sortedColumns.toString()); // for Mapper only task StringBuffer originalOrder = new StringBuffer(); for (int i = 0; i < projections.length; i++) { originalOrder.append(projections[i].getInputColumnName()); if (i < projections.length - 1) originalOrder.append(","); } job.set(datasetID + ".columns.in.original.order", originalOrder.toString()); }