List of usage examples for java.util SortedMap keySet
Set<K> keySet();
From source file:CollectionAll.java
public static void main(String[] args) { List list1 = new LinkedList(); list1.add("list"); list1.add("dup"); list1.add("x"); list1.add("dup"); traverse(list1);/*from www . jav a2s .c om*/ List list2 = new ArrayList(); list2.add("list"); list2.add("dup"); list2.add("x"); list2.add("dup"); traverse(list2); Set set1 = new HashSet(); set1.add("set"); set1.add("dup"); set1.add("x"); set1.add("dup"); traverse(set1); SortedSet set2 = new TreeSet(); set2.add("set"); set2.add("dup"); set2.add("x"); set2.add("dup"); traverse(set2); LinkedHashSet set3 = new LinkedHashSet(); set3.add("set"); set3.add("dup"); set3.add("x"); set3.add("dup"); traverse(set3); Map m1 = new HashMap(); m1.put("map", "Java2s"); m1.put("dup", "Kava2s"); m1.put("x", "Mava2s"); m1.put("dup", "Lava2s"); traverse(m1.keySet()); traverse(m1.values()); SortedMap m2 = new TreeMap(); m2.put("map", "Java2s"); m2.put("dup", "Kava2s"); m2.put("x", "Mava2s"); m2.put("dup", "Lava2s"); traverse(m2.keySet()); traverse(m2.values()); LinkedHashMap /* from String to String */ m3 = new LinkedHashMap(); m3.put("map", "Java2s"); m3.put("dup", "Kava2s"); m3.put("x", "Mava2s"); m3.put("dup", "Lava2s"); traverse(m3.keySet()); traverse(m3.values()); }
From source file:Main.java
public static void main(String[] args) { SortedMap<String, Integer> sortedMap = new TreeMap<String, Integer>(); sortedMap.put("A", 1); sortedMap.put("B", 2); sortedMap.put("C", 3); sortedMap.put("D", 4); sortedMap.put("E", 5); sortedMap.put("java2s", 6); System.out.println(sortedMap.keySet()); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step5bAgreementMeasures.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { String inputDir = args[0];// w ww. j av a 2 s. co m // all annotations List<AnnotatedArgumentPair> allArgumentPairs = new ArrayList<>(); Collection<File> files = IOHelper.listXmlFiles(new File(inputDir)); for (File file : files) { allArgumentPairs.addAll((List<AnnotatedArgumentPair>) XStreamTools.getXStream().fromXML(file)); } // for collecting the rank of n-th best worker per HIT SortedMap<Integer, DescriptiveStatistics> nThWorkerOnHITRank = new TreeMap<>(); // confusion matrix wrt. gold data for each n-th best worker on HIT SortedMap<Integer, ConfusionMatrix> nThWorkerOnHITConfusionMatrix = new TreeMap<>(); // initialize maps for (int i = 0; i < TOP_K_VOTES; i++) { nThWorkerOnHITRank.put(i, new DescriptiveStatistics()); nThWorkerOnHITConfusionMatrix.put(i, new ConfusionMatrix()); } for (AnnotatedArgumentPair argumentPair : allArgumentPairs) { // sort turker rank and their vote SortedMap<Integer, String> rankAndVote = new TreeMap<>(); System.out.println(argumentPair.mTurkAssignments.size()); for (AnnotatedArgumentPair.MTurkAssignment assignment : argumentPair.mTurkAssignments) { rankAndVote.put(assignment.getTurkRank(), assignment.getValue()); } String goldLabel = argumentPair.getGoldLabel(); System.out.println(rankAndVote); // top K workers for the HIT List<String> topKVotes = new ArrayList<>(rankAndVote.values()).subList(0, TOP_K_VOTES); // rank of top K workers List<Integer> topKRanks = new ArrayList<>(rankAndVote.keySet()).subList(0, TOP_K_VOTES); System.out.println("Top K votes: " + topKVotes); System.out.println("Top K ranks: " + topKRanks); // extract only category (a1, a2, or equal) List<String> topKVotesOnlyCategory = new ArrayList<>(); for (String vote : topKVotes) { String category = vote.split("_")[2]; topKVotesOnlyCategory.add(category); } System.out.println("Top " + TOP_K_VOTES + " workers' decisions: " + topKVotesOnlyCategory); if (goldLabel == null) { System.out.println("No gold label estimate for " + argumentPair.getId()); } else { // update statistics for (int i = 0; i < TOP_K_VOTES; i++) { nThWorkerOnHITConfusionMatrix.get(i).increaseValue(goldLabel, topKVotesOnlyCategory.get(i)); // rank is +1 (we don't start ranking from zero) nThWorkerOnHITRank.get(i).addValue(topKRanks.get(i) + 1); } } } for (int i = 0; i < TOP_K_VOTES; i++) { System.out.println("n-th worker : " + (i + 1) + " -----------"); System.out.println(nThWorkerOnHITConfusionMatrix.get(i).printNiceResults()); System.out.println(nThWorkerOnHITConfusionMatrix.get(i)); System.out.println("Average rank: " + nThWorkerOnHITRank.get(i).getMean() + ", stddev " + nThWorkerOnHITRank.get(i).getStandardDeviation()); } }
From source file:ListCharsets.java
static public void main(String args[]) throws Exception { SortedMap charsets = Charset.availableCharsets(); Set names = charsets.keySet(); for (Iterator e = names.iterator(); e.hasNext();) { String name = (String) e.next(); Charset charset = (Charset) charsets.get(name); System.out.println(charset); Set aliases = charset.aliases(); for (Iterator ee = aliases.iterator(); ee.hasNext();) { System.out.println(" " + ee.next()); }//from w w w . j av a 2 s.c o m } }
From source file:edu.cmu.sv.modelinference.eventtool.PredictionModel.java
private static DataPointCollection computeThreshold(SortedMap<Integer, Double> threshold) { DataPointCollection dp = new DataPointCollection(); for (int key : threshold.keySet()) { dp.add(new DataPoint(key, threshold.get(key))); }/*from www. ja va 2 s . c o m*/ return dp; }
From source file:org.eclipse.skalli.testutil.AssertUtils.java
public static void assertEquals(String message, SortedMap<?, ?> map, String... values) { Assert.assertEquals(message + "[size]", values.length, map.size()); int i = 0;// w w w . ja v a2 s .c o m for (Object o : map.keySet()) { Assert.assertEquals(message + "[" + i + "]", values[i], o.toString()); ++i; } }
From source file:annis.CSVHelper.java
public static void exportCSVData(Iterator<AnnotatedMatch> matches, SortedMap<Integer, SortedSet<String>> columnsByNodePos, PrintWriter w) { int count = columnsByNodePos.keySet().size(); // print values while (matches.hasNext()) { AnnotatedMatch match = matches.next(); List<String> line = new ArrayList<>(); int k = 0; for (; k < match.size(); ++k) { AnnotatedSpan span = match.get(k); Map<String, String> valueByName = new HashMap<>(); if (span != null) { if (span.getAnnotations() != null) { for (Annotation annotation : span.getAnnotations()) { valueByName.put("anno_" + annotation.getQualifiedName(), annotation.getValue()); }/*from w w w .java 2s .co m*/ } if (span.getMetadata() != null) { for (Annotation meta : span.getMetadata()) { valueByName.put("meta_" + meta.getQualifiedName(), meta.getValue()); } } line.add("" + span.getId()); line.add(span.getCoveredText().replace("\t", "\\t")); } for (String name : columnsByNodePos.get(k)) { if (valueByName.containsKey(name)) { line.add(valueByName.get(name).replace("\t", "\\t")); } else { line.add("'NULL'"); } } } for (int l = k; l < count; ++l) { line.add("'NULL'"); for (int m = 0; m <= columnsByNodePos.get(l).size(); ++m) { line.add("'NULL'"); } } w.append(StringUtils.join(line, "\t")); w.append("\n"); } }
From source file:com.ai.smart.bottom.helper.MacUtils.java
public static JSONObject sort(JSONObject json) { Set<String> iteratorKeys = json.keySet(); SortedMap<String, Object> map = new TreeMap<String, Object>(); for (String str : iteratorKeys) { map.put(str, json.get(str));//from w w w . j av a2 s . com } Set<String> mapkeys = map.keySet(); JSONObject json2 = new JSONObject(); for (String s : mapkeys) { json2.put(s, map.get(s)); } return json2; }
From source file:org.jenkinsci.plugins.rolestrategy.permissions.DangerousPermissionHelper.java
@CheckForNull public static boolean hasDangerousPermissions(@Nonnull RoleBasedAuthorizationStrategy strategy) { SortedMap<Role, Set<String>> grantedRoles = strategy.getGrantedRoles(RoleBasedAuthorizationStrategy.GLOBAL); return hasDangerousPermissions(grantedRoles.keySet()); }
From source file:org.jenkinsci.plugins.rolestrategy.permissions.DangerousPermissionHelper.java
/** * Prepare the report string about dangerous roles. * @param strategy Strategy//ww w . j a v a2s . c om * @return Summary report string describing dangerous roles. * {@code null} if all roles are fine. */ @CheckForNull public static String reportDangerousPermissions(@Nonnull RoleBasedAuthorizationStrategy strategy) { SortedMap<Role, Set<String>> grantedRoles = strategy.getGrantedRoles(RoleBasedAuthorizationStrategy.GLOBAL); return reportDangerousPermissions(grantedRoles.keySet()); }