/** * Constructor that copies the input map creating an independent copy. * <p> * This method performs different behaviour depending on whether the map * specified is a MultiMap or not. If a MultiMap is specified, each internal * collection is also cloned. If the specified map only implements Map, then * the values are not cloned. * <p> * NOTE: From Commons Collections 3.1 this method correctly copies a MultiMap * to form a truly independent new map. * NOTE: From Commons Collections 3.2 this method delegates to the newly * added putAll(Map) override method. * * @param mapToCopy a Map to copy */ public MultiHashMap(Map mapToCopy) { // be careful of JDK 1.3 vs 1.4 differences super((int) (mapToCopy.size() * 1.4f)); putAll(mapToCopy); }
/** * Constructor that copies the input map creating an independent copy. * <p> * This method performs different behaviour depending on whether the map * specified is a MultiMap or not. If a MultiMap is specified, each internal * collection is also cloned. If the specified map only implements Map, then * the values are not cloned. * <p> * NOTE: From Commons Collections 3.1 this method correctly copies a MultiMap * to form a truly independent new map. * NOTE: From Commons Collections 3.2 this method delegates to the newly * added putAll(Map) override method. * * @param mapToCopy a Map to copy */ public MultiHashMap(Map mapToCopy) { // be careful of JDK 1.3 vs 1.4 differences super((int) (mapToCopy.size() * 1.4f)); putAll(mapToCopy); }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * NOTE: Prior to version 3.2, putAll(map) did not work properly * when passed a MultiMap. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * NOTE: Prior to version 3.2, putAll(map) did not work properly * when passed a MultiMap. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
public void testPutAll_Map2() { Map original = new HashMap(); original.put("keyX", "object1"); original.put("keyY", "object2"); MultiHashMap test = new MultiHashMap(); test.put("keyA", "objectA"); test.put("keyX", "object0"); test.putAll(original); assertEquals(3, test.size()); assertEquals(4, test.totalSize()); assertEquals(1, test.getCollection("keyA").size()); assertEquals(2, test.getCollection("keyX").size()); assertEquals(1, test.getCollection("keyY").size()); assertEquals(true, test.containsValue("objectA")); assertEquals(true, test.containsValue("object0")); assertEquals(true, test.containsValue("object1")); assertEquals(true, test.containsValue("object2")); }
public void testPutAll_KeyCollection() { MultiHashMap map = new MultiHashMap(); Collection coll = Arrays.asList(new Object[] {"X", "Y", "Z"}); assertEquals(true, map.putAll("A", coll)); assertEquals(3, map.size("A")); assertEquals(true, map.containsValue("A", "X")); assertEquals(true, map.containsValue("A", "Y")); assertEquals(true, map.containsValue("A", "Z")); assertEquals(false, map.putAll("A", null)); assertEquals(3, map.size("A")); assertEquals(true, map.containsValue("A", "X")); assertEquals(true, map.containsValue("A", "Y")); assertEquals(true, map.containsValue("A", "Z")); assertEquals(false, map.putAll("A", new ArrayList())); assertEquals(3, map.size("A")); assertEquals(true, map.containsValue("A", "X")); assertEquals(true, map.containsValue("A", "Y")); assertEquals(true, map.containsValue("A", "Z")); coll = Arrays.asList(new Object[] {"M"}); assertEquals(true, map.putAll("A", coll)); assertEquals(4, map.size("A")); assertEquals(true, map.containsValue("A", "X")); assertEquals(true, map.containsValue("A", "Y")); assertEquals(true, map.containsValue("A", "Z")); assertEquals(true, map.containsValue("A", "M")); }
public void testPutAll_Map1() { MultiMap original = new MultiHashMap(); original.put("key", "object1"); original.put("key", "object2"); MultiHashMap test = new MultiHashMap(); test.put("keyA", "objectA"); test.put("key", "object0"); test.putAll(original); assertEquals(2, test.size()); assertEquals(4, test.totalSize()); assertEquals(1, test.getCollection("keyA").size()); assertEquals(3, test.getCollection("key").size()); assertEquals(true, test.containsValue("objectA")); assertEquals(true, test.containsValue("object0")); assertEquals(true, test.containsValue("object1")); assertEquals(true, test.containsValue("object2")); }
public void putAll( Map arg0 ) { map.putAll( arg0 ); }
/** * Constructor that copies the input map creating an independent copy. * <p> * This method performs different behaviour depending on whether the map * specified is a MultiMap or not. If a MultiMap is specified, each internal * collection is also cloned. If the specified map only implements Map, then * the values are not cloned. * <p> * NOTE: From Commons Collections 3.1 this method correctly copies a MultiMap * to form a truly independent new map. * NOTE: From Commons Collections 3.2 this method delegates to the newly * added putAll(Map) override method. * * @param mapToCopy a Map to copy */ public MultiHashMap(Map mapToCopy) { // be careful of JDK 1.3 vs 1.4 differences super((int) (mapToCopy.size() * 1.4f)); putAll(mapToCopy); }
/** * Constructor that copies the input map creating an independent copy. * <p> * This method performs different behaviour depending on whether the map * specified is a MultiMap or not. If a MultiMap is specified, each internal * collection is also cloned. If the specified map only implements Map, then * the values are not cloned. * <p> * NOTE: From Commons Collections 3.1 this method correctly copies a MultiMap * to form a truly independent new map. * NOTE: From Commons Collections 3.2 this method delegates to the newly * added putAll(Map) override method. * * @param mapToCopy a Map to copy */ public MultiHashMap(Map mapToCopy) { // be careful of JDK 1.3 vs 1.4 differences super((int) (mapToCopy.size() * 1.4f)); putAll(mapToCopy); }
/** * Constructor that copies the input map creating an independent copy. * <p> * This method performs different behaviour depending on whether the map * specified is a MultiMap or not. If a MultiMap is specified, each internal * collection is also cloned. If the specified map only implements Map, then * the values are not cloned. * <p> * NOTE: From Commons Collections 3.1 this method correctly copies a MultiMap * to form a truly independent new map. * NOTE: From Commons Collections 3.2 this method delegates to the newly * added putAll(Map) override method. * * @param mapToCopy a Map to copy */ public MultiHashMap(Map mapToCopy) { // be careful of JDK 1.3 vs 1.4 differences super((int) (mapToCopy.size() * 1.4f)); putAll(mapToCopy); }
/** * Constructor that copies the input map creating an independent copy. * <p> * This method performs different behaviour depending on whether the map * specified is a MultiMap or not. If a MultiMap is specified, each internal * collection is also cloned. If the specified map only implements Map, then * the values are not cloned. * <p> * NOTE: From Commons Collections 3.1 this method correctly copies a MultiMap * to form a truly independent new map. * NOTE: From Commons Collections 3.2 this method delegates to the newly * added putAll(Map) override method. * * @param mapToCopy a Map to copy */ public MultiHashMap(Map mapToCopy) { // be careful of JDK 1.3 vs 1.4 differences super((int) (mapToCopy.size() * 1.4f)); putAll(mapToCopy); }
/** * Constructor that copies the input map creating an independent copy. * <p> * This method performs different behaviour depending on whether the map * specified is a MultiMap or not. If a MultiMap is specified, each internal * collection is also cloned. If the specified map only implements Map, then * the values are not cloned. * <p> * NOTE: From Commons Collections 3.1 this method correctly copies a MultiMap * to form a truly independent new map. * NOTE: From Commons Collections 3.2 this method delegates to the newly * added putAll(Map) override method. * * @param mapToCopy a Map to copy */ public MultiHashMap(Map mapToCopy) { // be careful of JDK 1.3 vs 1.4 differences super((int) (mapToCopy.size() * 1.4f)); putAll(mapToCopy); }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * NOTE: Prior to version 3.2, putAll(map) did not work properly * when passed a MultiMap. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * NOTE: Prior to version 3.2, putAll(map) did not work properly * when passed a MultiMap. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * NOTE: Prior to version 3.2, putAll(map) did not work properly * when passed a MultiMap. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * NOTE: Prior to version 3.2, putAll(map) did not work properly * when passed a MultiMap. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * NOTE: Prior to version 3.2, putAll(map) did not work properly * when passed a MultiMap. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }