List of usage examples for java.util TreeMap putAll
public void putAll(Map<? extends K, ? extends V> map)
From source file:Main.java
public static void main(String[] args) { HashMap<String, Double> map = new HashMap<String, Double>(); ValueComparator bvc = new ValueComparator(map); TreeMap<String, Double> sorted_map = new TreeMap<String, Double>(bvc); map.put("A", 9.0); map.put("B", 6.0); map.put("C", 7.0); map.put("D", 10.0); System.out.println("unsorted map: " + map); sorted_map.putAll(map); System.out.println("results: " + sorted_map); }
From source file:BitLottoVerify.java
public static void main(String args[]) throws Exception { if (args.length < 3) { System.out.println("Args: blockhash megamillions addrs"); System.out.println(/* ww w . j a v a2 s. c om*/ "Example: 14avxyPW5PgA68kGkDkY1mCGPP8zqkywEx 000000000000042c91c9de46f802524ab1c2296923a72b55fac2d2c6fd7f4741 113538415240"); System.exit(1); } String blockhash = args[0]; String megamillions = args[1]; String mixer = blockhash + megamillions; String mixer_hash = sha256(blockhash + megamillions); System.out.println("Mixer: " + mixer); System.out.println("Mixer hash: " + mixer_hash); TreeMap<String, String> draw_map = new TreeMap<String, String>(); for (int i = 2; i < args.length; i++) { String addr = args[i]; System.out.println("Draw address: " + addr); draw_map.putAll(getDrawTxSet(addr, mixer_hash)); } System.out.println(); for (Map.Entry<String, String> me : draw_map.entrySet()) { System.out.println(me.getKey().substring(0, 8) + ": " + me.getValue()); } }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); TreeMap<Integer, String> treemap_putall = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); treemap_putall.put(1, "1"); treemap_putall.put(2, "2"); treemap_putall.put(7, "7"); System.out.println("Value before modification: " + treemap); // Putting 2nd map in 1st map treemap.putAll(treemap_putall); System.out.println("Value after modification: " + treemap); }
From source file:subsets.GenerateGFKMatrix.java
public static void main(String args[]) { CollectionTools ct = new CollectionTools(); GenerateGFKMatrix gfk = new GenerateGFKMatrix(); TreeMap<String, HashSet> SmartCube_SCAttribut = gfk.get_AType_Relation_BType("SmartCube", "SCAttribut", "MEMBER_OF", 1); TreeMap<String, HashSet> SCAttribut_BCAttribut_part1 = gfk.get_AType_Relation_BType("SCAttribut", "BCAttribut", "TRANSITION", -1); TreeMap<String, HashSet> SCAttribut_SCAlgo = gfk.get_AType_Relation_BType("SCAttribut", "SCAlgorithmen", "DERIVED_BY", -1); TreeMap<String, HashSet> SCAlgo_BCAttribut = gfk.get_AType_Relation_BType("SCAlgorithmen", "BCAttribut", "USES", -1); gfk.get_AType_Relation_BType("Meldekonzept", "BCAttribut", "USES", -1); //MATCH (c:Codeliste)<-[:MEMBER_OF]-(cd:Code) WHERE c.Name = "Geschaeftsfallkategorie_CL" RETURN c,cd HashSet gfks = gfk.getGFKs(); TreeMap<String, String> Meldekonzepte_formbeschreibung = gfk.getMeldekonzepte_formbeschreibung(); TreeMap<String, HashSet> Meldekonzept_GFK = new TreeMap(); for (String mk : Meldekonzepte_formbeschreibung.keySet()) { String form_beschreibung = Meldekonzepte_formbeschreibung.get(mk); Iterator it = gfks.iterator(); while (it.hasNext()) { String gfkategorie = (String) it.next(); if (form_beschreibung.contains(gfkategorie)) { HashSet dummy = Meldekonzept_GFK.get(mk); if (dummy == null) { dummy = new HashSet(); dummy.add(gfkategorie); Meldekonzept_GFK.put(mk, dummy); }/*from w ww. j av a 2 s . c om*/ dummy.add(gfkategorie); } } } TreeMap<String, HashSet> SmartCube_BCAttribut = ct .join_string_hashset_and_string_hashset(SmartCube_SCAttribut, SCAttribut_BCAttribut_part1); TreeMap<String, HashSet> SmartCube_SCAlgo = ct.join_string_hashset_and_string_hashset(SmartCube_SCAttribut, SCAttribut_SCAlgo); TreeMap<String, HashSet> SCAttribut_BCAttribut_part2 = ct .join_string_hashset_and_string_hashset(SmartCube_SCAlgo, SCAlgo_BCAttribut); TreeMap<String, HashSet> SCAttribut_BCAttribut = new TreeMap(); SCAttribut_BCAttribut.putAll(SCAttribut_BCAttribut_part1); SCAttribut_BCAttribut.putAll(SCAttribut_BCAttribut_part2); //TreeMap<String,JSONObject> SC_BC_Dependency = gfk.get_SC_BC_Dependency(); //Achtung: in der Klasse GenerateSCSubset sind alle Subsets definiert GenerateSCSubset gensubset = new GenerateSCSubset(); //Erzeuge alle Smart Cube Matrizen // TreeMap<String,TreeMap<String, HashSet>> dependency_structure= new TreeMap(); // // // ArrayList<Cube> all_cubes = gensubset.getCubeDependency_ArrayList(); // // //get all relevant Dimensions // //GFK - MappingTabelle GFK : TreeMap<String (GFK), Set of BC Attribute > TreeMap<String, HashSet> GFK_BCAttribut = new TreeMap(); //Hier wird eigentlcihe Dependency Matrix aufgebaut for (int i = 0; i < all_cubes.size(); i++) { System.out.println(((Cube) all_cubes.get(i)).Bezeichnung); Cube cube = all_cubes.get(i); for (String mk : cube.Meldekonzept_SCDimensionen.keySet()) { HashSet scattribute_pro_meldekonzept = cube.Meldekonzept_SCDimensionen.get(mk); Iterator it = scattribute_pro_meldekonzept.iterator(); //Meldekonzept get BCAttribute = MK_Basic Cube Attribut HashSet geschaeftsfallkategorien = Meldekonzept_GFK.get(mk); HashSet Meldekonzept_BCDependency = new HashSet(); //schritt fr schritt durchgehen while (it.hasNext()) {//gehe Attribute pro Meldekonzept druch String SCAttribut = (String) it.next(); HashSet BasicCubeAttribute = SCAttribut_BCAttribut.get(SCAttribut); // // // Fehler - SCAttribut_BCAttribut : Diese Datenstruktur enthaelt auch Cubes anstatt NUR SCAttribute // // //BasicCubeAttribute kann null sein ? Meldekonzept_BCDependency.addAll(BasicCubeAttribute); } Iterator gfk_iterator = geschaeftsfallkategorien.iterator(); while (gfk_iterator.hasNext()) { String gfkategorie = (String) gfk_iterator.next(); HashSet dummy = new HashSet(); dummy.addAll(Meldekonzept_BCDependency); GFK_BCAttribut.put(gfkategorie, dummy); } } all_cubes.get(i).showMeldekonzept_SCDimensionen(); } System.out.println("Test1234"); }
From source file:com.git.ifly6.components.Census.java
private static TreeMap<String, Integer> sortByValue(HashMap<String, Integer> map) { ValueComparator vc = new ValueComparator(map); TreeMap<String, Integer> sortedMap = new TreeMap<String, Integer>(vc); sortedMap.putAll(map); return sortedMap; }
From source file:io.warp10.continuum.DirectoryUtil.java
private static long computeHash(long k0, long k1, long timestamp, List<String> classSelectors, List<Map<String, String>> labelsSelectors) { ////w w w .ja v a 2s. c o m // Create a ByteArrayOutputStream into which the content will be dumped // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // Add timestamp try { baos.write(Longs.toByteArray(timestamp)); if (null != classSelectors) { for (String classSelector : classSelectors) { baos.write(classSelector.getBytes(Charsets.UTF_8)); } } if (null != labelsSelectors) { for (Map<String, String> map : labelsSelectors) { TreeMap<String, String> tm = new TreeMap<String, String>(); tm.putAll(map); for (Entry<String, String> entry : tm.entrySet()) { baos.write(entry.getKey().getBytes(Charsets.UTF_8)); baos.write(entry.getValue().getBytes(Charsets.UTF_8)); } } } } catch (IOException ioe) { return 0L; } // Compute hash byte[] data = baos.toByteArray(); long hash = SipHashInline.hash24(k0, k1, data, 0, data.length); return hash; }
From source file:org.opencastproject.index.service.util.ListProviderUtil.java
/** * Sorts the given map by its values, ascendantly or not * * @param map/*w ww .j ava 2 s .com*/ * The map to sort * @param ascending * If the sorting should be done ascendantly (true) or not * @return a sorted map */ public static Map<String, Object> sortMapByValue(Map<String, Object> map, boolean asc) { TreeMap<String, Object> treeMap = new TreeMap<String, Object>(new ValueComparer(map, asc)); treeMap.putAll(map); return treeMap; }
From source file:kr.co.aim.nanoframe.orm.SQLLogUtil.java
public static String getLogFormatSqlStatement(String sql, Object args, Log log) { try {/* w ww. ja v a 2 s .c om*/ if (args instanceof Map) { Map<String, Object> map = (Map<String, Object>) args; TreeMap<String, Object> treeMap = new TreeMap<String, Object>(stringComparator); treeMap.putAll(map); Iterator<Entry<String, Object>> iter = treeMap.entrySet().iterator(); while (iter.hasNext()) { Entry<String, Object> entry = iter.next(); sql = sql.replace(":" + entry.getKey(), getLogFormatArgument(entry.getValue())); } } else if (args instanceof Object[]) { Object[] objs = (Object[]) args; for (Object obj : objs) { sql = StringUtils.replaceOnce(sql, "?", getLogFormatArgument(obj)); } } } catch (Throwable t) { if (log.isDebugEnabled()) log.error(t, t); else log.error(t); } return sql; }
From source file:Main.java
private static ArrayList<ArrayList> sortObjectArrayListSimpleMaster(ArrayList listIn, String paramName) { ArrayList<ArrayList> answer = new ArrayList<ArrayList>(); ArrayList newList = new ArrayList(); ArrayList<Integer> indices = new ArrayList<Integer>(); try {/*from w ww . j av a 2 s.co m*/ if (listIn.size() > 0) { Class<?> c = listIn.get(0).getClass(); Field f = c.getDeclaredField(paramName); f.setAccessible(true); Class<?> t = f.getType(); Double dd = new Double(14); Float ff = new Float(14); Integer ii = new Integer(14); Map sortedPos = new LinkedHashMap(); Map sortedNeg = new LinkedHashMap(); Map unsorted = new LinkedHashMap(); int indexCount = 0; long count = 0; if (t.isPrimitive()) { for (Object thisObj : listIn) { Object o = f.get(thisObj); double d = 0; if (t.getName().equals("char")) { d = (int) ((Character) o); } else if (t.isInstance(dd)) d = (Double) o; else if (t.isInstance(ff)) d = (Float) o; else if (t.isInstance(ii)) d = (Integer) o; else d = new Double(o.toString()); boolean isNegative = false; if (d < 0) { isNegative = true; d = Math.abs(d); } String format = "%1$30f"; String newKey = String.format(format, d); String format2 = "%1$20d"; String countString = String.format(format2, count); newKey += "-" + countString; if (isNegative) { sortedNeg.put(newKey, thisObj); } else { sortedPos.put(newKey, thisObj); } unsorted.put(thisObj, indexCount); count++; indexCount++; } TreeMap<String, Object> resultPos = new TreeMap(); resultPos.putAll(sortedPos); sortedPos = resultPos; TreeMap<String, Object> resultNeg = new TreeMap(); resultNeg.putAll(sortedNeg); sortedNeg = resultNeg; } else if (t.isInstance(paramName)) { // System.out.println("is a string with value " + o); for (Object thisObj : listIn) { String key = (String) (f.get(thisObj)); sortedPos.put(key + "-" + count, thisObj); unsorted.put(thisObj, indexCount); count++; indexCount++; } TreeMap<String, Object> result = new TreeMap(String.CASE_INSENSITIVE_ORDER); result.putAll(sortedPos); sortedPos = result; } Iterator itNeg = sortedNeg.entrySet().iterator(); while (itNeg.hasNext()) { Map.Entry pairs = (Map.Entry) itNeg.next(); newList.add(pairs.getValue()); itNeg.remove(); } Collections.reverse(newList); Iterator itPos = sortedPos.entrySet().iterator(); while (itPos.hasNext()) { Map.Entry pairs = (Map.Entry) itPos.next(); Object obj = pairs.getValue(); newList.add(obj); indices.add((Integer) unsorted.get(obj)); itPos.remove(); } } } catch (Exception e) { System.out .println("problem sorting list. listIn.size(): " + listIn.size() + " and param: " + paramName); answer.add(newList); answer.add(indices); return answer; } answer.add(newList); answer.add(indices); return answer; }
From source file:com.github.benyzhous.springboot.web.core.gateway.sign.backend.Sign.java
/** * Uri+???//from w w w . j a v a 2 s. c o m * * @param uri HTTPuri,??Query * @param paramsMap HTTP?Query+Form? * @return Uri+??? */ private static String buildResource(String uri, Map<String, Object> paramsMap) { StringBuilder builder = new StringBuilder(); // uri builder.append(uri); // Query+Form TreeMap<String, Object> sortMap = new TreeMap<String, Object>(); sortMap.putAll(paramsMap); // Query+Form? if (sortMap.size() > 0) { builder.append('?'); builder.append(buildMapToSign(sortMap)); } return builder.toString(); }