List of usage examples for java.util WeakHashMap putAll
public void putAll(Map<? extends K, ? extends V> m)
From source file:Main.java
public static void main(String[] args) { WeakHashMap<String, String> weakHashMapOne = new WeakHashMap<String, String>(); WeakHashMap<String, String> weakHashMapTwo = new WeakHashMap<String, String>(); System.out.println("Populating two Maps"); weakHashMapOne.put("1", "first"); weakHashMapOne.put("2", "two"); weakHashMapOne.put("3", "from java2s.com"); weakHashMapTwo.put("1", "1st"); weakHashMapTwo.put("2", "2nd"); weakHashMapTwo.put("3", "3rd"); // checking Map System.out.println("Before - Map 1: " + weakHashMapOne); System.out.println("Before - Map 2: " + weakHashMapTwo); // putting map 2 into map1 weakHashMapOne.putAll(weakHashMapTwo); System.out.println("After - Map 1: " + weakHashMapOne); System.out.println("After - Map 2: " + weakHashMapTwo); }
From source file:MethodHashing.java
public static long calculateHash(Method method) { Map methodHashes = (Map) hashMap.get(method.getDeclaringClass()); if (methodHashes == null) { methodHashes = getInterfaceHashes(method.getDeclaringClass()); // Copy and add WeakHashMap newHashMap = new WeakHashMap(); newHashMap.putAll(hashMap); newHashMap.put(method.getDeclaringClass(), methodHashes); hashMap = newHashMap;//from w ww.j ava 2 s .co m } return ((Long) methodHashes.get(method.toString())).longValue(); }