List of usage examples for java.util SortedSet addAll
boolean addAll(Collection<? extends E> c);
From source file:io.wcm.devops.conga.plugins.sling.util.ProvisioningUtil.java
/** * Get the relative path for a configuration *///from w w w. j av a2s . co m private static String getPathForConfiguration(Configuration configuration, RunMode runMode) { SortedSet<String> runModesList = new TreeSet<>(); if (runMode.getNames() != null) { runModesList.addAll(ImmutableList.copyOf(runMode.getNames())); } // run modes directory StringBuilder path = new StringBuilder(); if (!runModesList.isEmpty() && !runMode.isSpecial()) { path.append(StringUtils.join(runModesList, ".")).append("/"); } // main name if (configuration.getFactoryPid() != null) { path.append(configuration.getFactoryPid()).append("-"); } path.append(configuration.getPid()).append(".config"); return path.toString(); }
From source file:org.springframework.integration.print.core.PrintServiceExecutor.java
public static SortedSet<PrintService> getAvailablePrinterServices() { PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null); printServices[0].getName();//from ww w . j a va 2s. co m SortedSet<PrintService> printServicesList = new TreeSet<PrintService>(new PrintServiceComparator()); printServicesList.addAll(Arrays.asList(printServices)); return printServicesList; }
From source file:org.eclipse.sw360.licenseinfo.outputGenerators.OutputGenerator.java
/** * Helper function to sort a set by the given key extractor. Falls back to the * unsorted set if sorting the set would squash values. * * @param unsorted/*from w ww . ja v a2 s. co m*/ * set to be sorted * @param keyExtractor * function to extract the key to use for sorting * * @return the sorted set */ private static <U, K extends Comparable<K>> SortedSet<U> sortSet(Set<U> unsorted, Function<U, K> keyExtractor) { if (unsorted == null || unsorted.isEmpty()) { return Collections.emptySortedSet(); } SortedSet<U> sorted = new TreeSet<>(Comparator.comparing(keyExtractor)); sorted.addAll(unsorted); if (sorted.size() != unsorted.size()) { // there were key collisions and some data was lost -> throw away the sorted set // and sort by U's natural order sorted = new TreeSet<>(); sorted.addAll(unsorted); } return sorted; }
From source file:Main.java
/** * Creates a map which is sorted by entry values. * /*w w w . ja v a 2 s. co m*/ * @param map the original map * * @param <K> the key type * @param <V> the value type * * @return a map which is by entry values. */ public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> getEntriesSortedByValues( Map<K, V> map) { SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>(new Comparator<Map.Entry<K, V>>() { @Override public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) { return e1.getValue().compareTo(e2.getValue()); } }); sortedEntries.addAll(map.entrySet()); return sortedEntries; }
From source file:pt.ist.fenixedu.contracts.domain.organizationalStructure.Function.java
public static SortedSet<Function> getOrderedFunctions(Unit unit) { SortedSet<Function> functions = new TreeSet<Function>(Function.COMPARATOR_BY_ORDER); functions.addAll(unit.getFunctionsSet()); return functions; }
From source file:io.hops.experiments.results.compiler.InterleavedBMResultsAggregator.java
public static void combineResults(Map<String, Map<Integer, InterleavedAggregate>> hdfsAllWorkLoads, Map<String, Map<Integer, InterleavedAggregate>> hopsfsAllWorkloas, String outpuFolder) throws IOException { String plot = "set terminal postscript eps enhanced color font \"Helvetica,18\" #monochrome\n"; plot += "set output '| ps2pdf - interleaved.pdf'\n"; plot += "#set size 1,0.75 \n "; plot += "set ylabel \"ops/sec\" \n"; plot += "set xlabel \"Number of Namenodes\" \n"; plot += "set format y \"%.0s%c\"\n"; plot += "plot "; for (String workload : hopsfsAllWorkloas.keySet()) { Map<Integer, InterleavedAggregate> hopsWorkloadResult = hopsfsAllWorkloas.get(workload); Map<Integer, InterleavedAggregate> hdfsWorkloadResult = hdfsAllWorkLoads.get(workload); if (hopsWorkloadResult == null) { System.out.println("No data for hopsfs for workload " + workload); return; }/*w ww . ja v a 2s . co m*/ double hdfsVal = 0; if (hdfsWorkloadResult != null) { if (hdfsWorkloadResult.keySet().size() > 1) { System.out.println("NN count for HDFS cannot be greater than 1"); return; } if (hdfsWorkloadResult.keySet().size() == 1) { hdfsVal = ((InterleavedAggregate) hdfsWorkloadResult.values().toArray()[0]).getSpeed(); } } if (hopsWorkloadResult.keySet().size() <= 0) { return; } plot += " '" + workload + "-interleaved.dat' using 2:xticlabels(1) not with lines, '' using 0:2:3:4:xticlabels(1) title \"HopsFS-" + workload + "\" with errorbars, " + hdfsVal + " title \"HDFS-" + workload + "\" \n"; String data = ""; SortedSet<Integer> sorted = new TreeSet<Integer>(); // Sort my number of NN sorted.addAll(hopsWorkloadResult.keySet()); for (Integer nn : sorted) { InterleavedAggregate agg = hopsWorkloadResult.get(nn); data += CompileResults.format(nn + "") + CompileResults.format(agg.getSpeed() + "") + CompileResults.format(agg.getMinSpeed() + "") + CompileResults.format(agg.getMaxSpeed() + "") + "\n"; } System.out.println(data); CompileResults.writeToFile(outpuFolder + "/" + workload + "-interleaved.dat", data, false); } System.out.println(plot); CompileResults.writeToFile(outpuFolder + "/interleaved.gnuplot", plot, false); }
From source file:com.github.fge.jsonschema.keyword.digest.draftv3.DraftV3DependenciesDigester.java
private static JsonNode sortedSet(final JsonNode node) { final SortedSet<JsonNode> set = Sets.newTreeSet(new Comparator<JsonNode>() { @Override//from w w w . j ava 2s .co m public int compare(final JsonNode o1, final JsonNode o2) { return o1.textValue().compareTo(o2.textValue()); } }); set.addAll(Sets.newHashSet(node)); final ArrayNode ret = FACTORY.arrayNode(); ret.addAll(set); return ret; }
From source file:Main.java
/** * Sorts entry set by values in ascending order. * /*from ww w . j a va2s. c o m*/ * @param map * @return sorted entry set. */ public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> sortByValuesAscending( Map<K, V> map) { SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>(new Comparator<Map.Entry<K, V>>() { @Override public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) { int result = e1.getValue().compareTo(e2.getValue()); return result != 0 ? result : 1; // saves equal entries } }); sortedEntries.addAll(map.entrySet()); return sortedEntries; }
From source file:Main.java
/** * Sorts entry set by values in descending order. * /*from w ww .j av a2s . c o m*/ * @param map * @return sorted entry set. */ public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> sortByValuesDescending( Map<K, V> map) { SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>(new Comparator<Map.Entry<K, V>>() { @Override public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) { int result = e2.getValue().compareTo(e1.getValue()); return result != 0 ? result : 1; // saves equal entries } }); sortedEntries.addAll(map.entrySet()); return sortedEntries; }
From source file:Main.java
public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues( Map<K, V> map) {/*from ww w . j a v a 2 s . co m*/ SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>(new Comparator<Map.Entry<K, V>>() { @Override public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) { int res = e1.getValue().compareTo(e2.getValue()); /* Preserve items with equal values */ return res != 0 ? res : 1; } }); sortedEntries.addAll(map.entrySet()); return sortedEntries; }