List of usage examples for java.util TreeMap entrySet
EntrySet entrySet
To view the source code for java.util TreeMap entrySet.
Click Source Link
From source file:com.data2semantics.yasgui.mgwtlinker.linker.PermutationMapLinker.java
protected Map<String, Set<BindingProperty>> buildPermutationMap(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException { HashMap<String, Set<BindingProperty>> map = new HashMap<String, Set<BindingProperty>>(); for (SelectionInformation result : artifacts.find(SelectionInformation.class)) { Set<BindingProperty> list = new HashSet<BindingProperty>(); map.put(result.getStrongName(), list); TreeMap<String, String> propMap = result.getPropMap(); Set<Entry<String, String>> set = propMap.entrySet(); for (Entry<String, String> entry : set) { BindingProperty bindingProperty = new BindingProperty(entry.getKey(), entry.getValue()); list.add(bindingProperty);//from w ww . j ava 2 s .c om } } return map; }
From source file:com.mycompany.task1.Chart.java
private void group(TreeMap<Double, Integer> groupedMap, Map<Double, Integer> mapa) { // przejdz przez pogrupowana mape i zwieksz wartosc jezeli wartosc klucza z niepogrupowanej mapy //znajduje sie w przedziale for (Map.Entry<Double, Integer> entry : mapa.entrySet()) { double prevRange = 0; for (Map.Entry<Double, Integer> entryGroupedMap : groupedMap.entrySet()) { if (prevRange <= entry.getKey() && entry.getKey() <= entryGroupedMap.getKey()) { int numberOfAccurence = entryGroupedMap.getValue(); numberOfAccurence++;/*from w w w . ja v a2s . com*/ groupedMap.put(entryGroupedMap.getKey(), numberOfAccurence); } prevRange = entryGroupedMap.getKey(); } } }
From source file:org.modeshape.web.jcr.rest.handler.RestItemHandlerImpl.java
private void addMultipleNodes(Request request, TreeMap<String, JsonNode> nodesByPath, Session session) throws RepositoryException { List<RestItem> result = new ArrayList<RestItem>(); for (Map.Entry<String, JsonNode> nodePath : nodesByPath.entrySet()) { String parentAbsPath = parentPath(nodePath.getKey()); String newNodeName = newNodeName(nodePath.getKey()); Node parentNode = (Node) session.getItem(parentAbsPath); Node newNode = addNode(parentNode, newNodeName, nodePath.getValue()); RestItem restNewNode = createRestItem(request, 0, session, newNode); result.add(restNewNode);//from w ww. ja v a2 s . c o m } session.save(); }
From source file:org.lockss.servlet.DisplayContentTab.java
public static TreeMap<String, TreeMap<String, TreeSet<ArchivalUnit>>> getAusByPluginName(Character start, Character end, String filterType, String filterKey) { TreeMap<String, TreeMap<String, TreeSet<ArchivalUnit>>> aus = new TreeMap<String, TreeMap<String, TreeSet<ArchivalUnit>>>(); TreeMap<String, TreeMap<String, TreeSet<ArchivalUnit>>> allAus; if ("none".equals(filterType)) { allAus = DisplayContentTable.orderAusByPluginAndTitle(TdbUtil.getConfiguredAus(), filterKey); } else {/*www . j av a 2 s . c om*/ allAus = DisplayContentTable.orderAusByPluginAndTitle(filterAus(TdbUtil.getConfiguredAus(), filterType), filterKey); } for (int i = start; i < end; i++) { for (Map.Entry<String, TreeMap<String, TreeSet<ArchivalUnit>>> stringTreeSetEntry : allAus.entrySet()) { Map.Entry<String, TreeMap<String, TreeSet<ArchivalUnit>>> pairs = (Map.Entry) stringTreeSetEntry; String pluginName = pairs.getKey().toLowerCase(); String startLetter = Character.toString((char) i); if (pluginName.startsWith(startLetter.toLowerCase())) { aus.put(pairs.getKey(), pairs.getValue()); } } } return aus; }
From source file:org.lockss.servlet.DisplayContentTab.java
public static TreeMap<String, TreeMap<String, TreeSet<ArchivalUnit>>> getAusByPublisherName(Character start, Character end, String filterType, String filterKey) { TreeMap<String, TreeMap<String, TreeSet<ArchivalUnit>>> aus = new TreeMap<String, TreeMap<String, TreeSet<ArchivalUnit>>>(); TreeMap<String, TreeMap<String, TreeSet<ArchivalUnit>>> allAus; if ("none".equals(filterType)) { allAus = DisplayContentTable.orderAusByPublisherAndTitle(TdbUtil.getConfiguredAus(), filterKey); } else {/*from ww w. ja v a 2 s .c o m*/ allAus = DisplayContentTable .orderAusByPublisherAndTitle(filterAus(TdbUtil.getConfiguredAus(), filterType), filterKey); } for (int i = start; i < end; i++) { for (Map.Entry<String, TreeMap<String, TreeSet<ArchivalUnit>>> stringTreeSetEntry : allAus.entrySet()) { Map.Entry<String, TreeMap<String, TreeSet<ArchivalUnit>>> pairs = (Map.Entry) stringTreeSetEntry; String publisherName = pairs.getKey().toLowerCase(); String startLetter = Character.toString((char) i); if (publisherName.startsWith(startLetter.toLowerCase())) { aus.put(pairs.getKey(), pairs.getValue()); } } } return aus; }
From source file:org.openecomp.sdnc.sli.SvcLogicNode.java
public void printAsGv(PrintStream pstr) { if (visited) { return;//from w ww . ja v a 2 s . c o m } else { visited = true; } StringBuffer sbuff = new StringBuffer(); sbuff.append("node"); sbuff.append(nodeId); sbuff.append(" [ shape=none, margin=0, label=<<table border=\"0\" cellborder=\"1\" align=\"left\">"); sbuff.append("<tr><td colspan=\"2\"><b>"); sbuff.append(nodeId); sbuff.append(" : "); sbuff.append(nodeType); sbuff.append("</b></td></tr><th><td><i>Attribute</i></td><td><i>Value</i></td></th>"); if (nodeName.length() > 0) { sbuff.append("<tr><td>name</td><td>"); sbuff.append(nodeName); sbuff.append("</td></tr>"); } Set<Map.Entry<String, SvcLogicExpression>> attrSet = attributes.entrySet(); for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = attrSet.iterator(); iter.hasNext();) { Map.Entry<String, SvcLogicExpression> curAttr = iter.next(); sbuff.append("<tr><td>"); sbuff.append(curAttr.getKey()); sbuff.append("</td><td>"); sbuff.append(StringEscapeUtils.escapeHtml3(curAttr.getValue().toString())); sbuff.append("</td></tr>"); } sbuff.append("</table>>];"); pstr.println(sbuff.toString()); if (outcomes != null) { TreeMap<String, SvcLogicNode> sortedOutcomes = new TreeMap<String, SvcLogicNode>(outcomes); Set<Map.Entry<String, SvcLogicNode>> outcomeSet = sortedOutcomes.entrySet(); for (Iterator<Map.Entry<String, SvcLogicNode>> iter = outcomeSet.iterator(); iter.hasNext();) { Map.Entry<String, SvcLogicNode> curOutcome = iter.next(); String outValue = curOutcome.getKey(); SvcLogicNode outNode = curOutcome.getValue(); pstr.println("node" + nodeId + " -> node" + outNode.getNodeId() + " [label=\"" + outValue + "\"];"); outNode.printAsGv(pstr); } } }
From source file:edu.synth.state.SyntHelperState.java
public void handleObsData() throws IOException { File obsFile = new File(Constants.OBS_DATA); TreeMap<Double, Double> obs = FileWorker.getSortedDoubleData(obsFile); synthSettings.setStartSynth(new BigDecimal(obs.firstKey()).setScale(0, RoundingMode.DOWN).intValue()); synthSettings.setEndSynth(new BigDecimal(obs.lastKey()).setScale(0, RoundingMode.UP).intValue()); List<String> strs = new ArrayList<String>(); for (Entry<Double, Double> ent : obs.entrySet()) strs.add(String.format(Locale.ENGLISH, "%1.4f %1.4f", ent.getKey(), ent.getValue())); FileWorker.write(obsFile, strs);//from w w w. ja v a 2 s .c o m }
From source file:org.sonarqube.cppcheck.CppcheckRuleRepositoryTest.java
public static void generate() throws Exception { PrintWriter writer = new PrintWriter(new FileWriter("target/generated-cppcheck.xml")); TreeMap<String, RuleDescription> map = Maps.newTreeMap(); String prevVersion = ""; for (String version : listVersions()) { for (CppcheckXmlParser.Message msg : CppcheckXmlParser .parse(new File("src/main/files/cppcheck-" + version + ".xml"))) { RuleDescription ruleDescription = map.get(msg.getId()); if (ruleDescription == null) { // new rule ruleDescription = new RuleDescription(); map.put(msg.getId(), ruleDescription); ruleDescription.minVersion = version; } else { // existing rule if (!prevVersion.equals(ruleDescription.maxVersion)) { System.err.println("Merge of rule, which appear and disappear from version to version: " + msg.getId()); }//from w w w . j a v a2 s . c o m } ruleDescription.maxVersion = version; // Supposed that message from newer version is better ruleDescription.msg = msg; } prevVersion = version; } Properties replacements = loadReplacements(); writer.println("<results version=\"2\">"); writer.println("<errors>"); for (Map.Entry<String, RuleDescription> entry : map.entrySet()) { RuleDescription description = entry.getValue(); final String versions; if (description.maxVersion.equals(prevVersion)) { versions = " (since Cppcheck " + description.minVersion + ")"; } else if (description.minVersion.equals(description.maxVersion)) { versions = " (Cppcheck " + description.minVersion + ")"; } else { versions = " (Cppcheck " + description.minVersion + "-" + description.maxVersion + ")"; } writer.append("<error "); if (replacements.containsKey(entry.getKey())) { writer.append("SonarQube=\"").append(replacements.getProperty(entry.getKey())).append("\"\n "); } writer.append("id=\"").append(entry.getKey()).append("\" msg=\"") .append(StringEscapeUtils.escapeXml(description.msg.getMsg() + versions)) .append("\" verbose=\"").append(StringEscapeUtils.escapeXml(description.msg.getVerbose())) .append("\" />").println(); } writer.println("</errors>"); writer.println("</results>"); writer.close(); }
From source file:ldbc.snb.datagen.generator.BTERKnowsGenerator.java
@Override public void generateKnows(ArrayList<Person> persons, int seed, ArrayList<Float> percentages, int step_index) { graphSize = persons.size();/*from ww w.j a v a 2 s.co m*/ expectedDegree = new long[graphSize]; adjacencyMatrix = new RoaringBitmap[graphSize]; p = new double[graphSize]; for (int i = 0; i < graphSize; ++i) { adjacencyMatrix[i] = new RoaringBitmap(); } random = new Random(); random.setSeed(seed); openCommunities.clear(); closedCommunities.clear(); smallDegreeNodes.clear(); int maxExpectedDegree = 0; for (int i = 0; i < graphSize; ++i) { adjacencyMatrix[i].clear(); expectedDegree[i] = Knows.targetEdges(persons.get(i), percentages, step_index); maxExpectedDegree = maxExpectedDegree < expectedDegree[i] ? (int) expectedDegree[i] : maxExpectedDegree; } p = new double[maxExpectedDegree + 1]; /** Initializing the array of triangles **/ ArrayList<Pair<Long, Double>> ccDistribution = new ArrayList<Pair<Long, Double>>(); try { BufferedReader reader = new BufferedReader( new InputStreamReader( getClass().getResourceAsStream( conf.get("ldbc.snb.datagen.generator.BTERKnowsGenerator.ccDistribution")), "UTF-8")); String line; while ((line = reader.readLine()) != null) { String data[] = line.split(" "); ccDistribution.add(new Pair<Long, Double>(Long.parseLong(data[0]), Double.parseDouble(data[1]))); } reader.close(); } catch (IOException e) { e.printStackTrace(); } p[0] = 0.0; p[1] = 0.0; for (int i = 2; i < maxExpectedDegree + 1; ++i) { int degree = i; int pos = binarySearch(ccDistribution, (long) degree); if (ccDistribution.get(pos).getKey() == degree || pos == (ccDistribution.size() - 1)) { p[degree] = ccDistribution.get(pos).getValue(); } else if (pos < ccDistribution.size() - 1) { long minDegree = ccDistribution.get(pos).getKey(); long maxDegree = ccDistribution.get(pos + 1).getKey(); double ratio = (degree - minDegree) / (maxDegree - minDegree); double minCC = ccDistribution.get(pos).getValue(); double maxCC = ccDistribution.get(pos + 1).getValue(); double cc_current = ratio * (maxCC - minCC) + minCC; p[degree] = Math.pow(cc_current, 1 / 3.0); } } RoaringBitmap block = new RoaringBitmap(); for (int i = 0; i < graphSize; ++i) { if (expectedDegree[i] > 1) { block.add(i); } else { smallDegreeNodes.add(i); } } generateCommunities(block); TreeMap<Long, RoaringBitmap> sortedMap = new TreeMap<Long, RoaringBitmap>(openCommunities); RoaringBitmap currentCommunity = null; long currentCommunitySize = 0; for (Map.Entry<Long, RoaringBitmap> community : sortedMap.entrySet()) { RoaringBitmap nextCommunity = community.getValue(); if (currentCommunity == null) { currentCommunity = nextCommunity; currentCommunitySize = community.getKey(); } else { while (currentCommunity.getCardinality() <= currentCommunitySize && nextCommunity.getCardinality() > 0) { int nextNode = nextCommunity.select(0); currentCommunity.add(nextNode); nextCommunity.remove(nextNode); } if (currentCommunity.getCardinality() >= currentCommunitySize) { closedCommunities.add(currentCommunity); currentCommunity = null; currentCommunitySize = 0; if (nextCommunity.getCardinality() > 0) { currentCommunity = nextCommunity; currentCommunitySize = community.getKey(); } } } } openCommunities.clear(); for (RoaringBitmap community : closedCommunities) { generateEdgesInCommunity(community); } generateRemainingEdges(); for (int i = 0; i < graphSize; ++i) { Iterator<Integer> it = adjacencyMatrix[i].iterator(); while (it.hasNext()) { int next = it.next(); Knows.createKnow(random, persons.get(i), persons.get(next)); } } }
From source file:webcralwerproject1.Webcrawler.java
public void writeTermfrequency() { try {/*from w ww .jav a 2s. co m*/ FileWriter f_write = new FileWriter("./crawler" + crawlcount + "output.txt"); BufferedWriter writer = new BufferedWriter(f_write); TreeMap<String, Integer> sortedMap = sortTermFreq(termfrequency); Set set = sortedMap.entrySet(); // Get an iterator Iterator i = set.iterator(); // Display elements while (i.hasNext()) { Map.Entry me = (Map.Entry) i.next(); writer.write(me.getKey() + " " + me.getValue()); writer.newLine(); } writer.close(); termfrequency.clear(); } catch (Exception e) { System.out.println("Inside writerTermFrequency : " + e); } }