public void add(HashMap<String, ArrayList<TaskMessage>> workerTupleSetMap) { for (String key : workerTupleSetMap.keySet()) { ArrayList<ArrayList<TaskMessage>> bundle = bundles.get(key); if (null == bundle) { bundle = new ArrayList<>(); bundles.put(key, bundle); } ArrayList tupleSet = workerTupleSetMap.get(key); if (null != tupleSet && tupleSet.size() > 0) { bundle.add(tupleSet); } } }
@Override protected void merge(HashMap<Value, Integer> in1, HashMap<Value, Integer> in2, HashMap<Value, Integer> out) { // Copy over in1. This will be the baseline out.putAll(in1); // Merge in in2. Make sure that we do not have ambiguous values. for (Value val : in2.keySet()) { Integer i1 = in1.get(val); Integer i2 = in2.get(val); if (i2.equals(i1)) { out.put(val, i2); } else { throw new RuntimeException("Merge of different IDs not supported"); } } } }
public Enumeration<String> getInitParameterNames() { if (!done.getAndSet(true)) { Enumeration en = sc.getInitParameterNames(); if (en != null) { while (en.hasMoreElements()) { String name = (String) en.nextElement(); if (!initParams.containsKey(name)) { initParams.put(name, sc.getInitParameter(name)); } } } } return Collections.enumeration(initParams.keySet()); } };
public String[][] getHeaders(Object value, Operation operation) throws ServiceException { Response delegate = (Response) value; HashMap map = new HashMap(); if (delegate.getContentDisposition() != null) { map.put("Content-Disposition", delegate.getContentDisposition()); } HashMap m = delegate.getResponseHeaders(); if (m != null && !m.isEmpty()) { map.putAll(m); } if (map == null || map.isEmpty()) return null; String[][] headers = new String[map.size()][2]; List keys = new ArrayList(map.keySet()); for (int i = 0; i < headers.length; i++) { headers[i][0] = (String) keys.get(i); headers[i][1] = (String) map.get(keys.get(i)); } return headers; }
public void foo() { m.put("a", "a"); Set<Map.Entry<Integer, Integer>> es = new HashSet<Map.Entry<Integer, Integer>>(); boolean b1 = m.entrySet().contains(1); // bad boolean b2 = m.keySet().contains(1); // ok boolean b3 = m.values().contains(1); // ok boolean b4 = m.entrySet().equals(es); // ok boolean b5 = m.entrySet().equals(is); // bad m.entrySet().contains(1); // bad boolean b6 = m.keySet().equals(is); // ok boolean b7 = m.values().equals(is); // ok System.out.printf("%b %b %b %b %b %b %b\n", b1, b2, b3, b4, b5, b6, b7); } }
private void calcAV() { System.out.println("count: "+left.size()); Iterator<String> it = left.keySet().iterator(); while(it.hasNext()){ String key = it.next(); Double l = Math.log(left.get(key).size()); Double r = Math.log(right.get(key).size()); av.put(key, (int)Math.min(l, r)); } System.out.println("av count: "+av.size()); }
private static void addBucketsToResultsCommon( HashMap<String, FileStatus> taskIDToFile, int numBuckets, List<Path> result) { String taskID1 = taskIDToFile.keySet().iterator().next(); Path bucketPath = taskIDToFile.values().iterator().next().getPath(); for (int j = 0; j < numBuckets; ++j) { addBucketFileIfMissing(result, taskIDToFile, taskID1, bucketPath, j); } }
@Nullable private HashMap<Character, Mark> getAllFileMarks(@NotNull final Document doc) { VirtualFile vf = FileDocumentManager.getInstance().getFile(doc); if (vf == null) { return null; } HashMap<Character, Mark> res = new HashMap<>(); FileMarks<Character, Mark> fileMarks = getFileMarks(doc); if (fileMarks != null) { res.putAll(fileMarks); } for (Character ch : globalMarks.keySet()) { Mark mark = globalMarks.get(ch); if (vf.getPath().equals(mark.getFilename())) { res.put(ch, mark); } } return res; }