@Test public void testPutAll() { HashMap<String, String> mapToPut = new HashMap<String, String>(); for (int i = 5; i < 10; i++) { mapToPut.put("key " + i, "value " + i); } map.putAll(mapToPut); assertEquals("map.size()", mapInitialSize + mapToPut.size(), map.size()); Object[] keys = map.keyArray(); assertEquals("map.keyArray().length", mapInitialSize + mapToPut.size(), keys.length); for (int i = 5; i < 10; i++) { assertEquals("map.get()", "value " + i, map.get("key " + i)); } }
@SuppressWarnings("unchecked") public void putAll(Map<? extends K, ? extends V> other) { if (other == null || other.size() == 0) { return; } if (other instanceof OrderPreservingMap) { final OrderPreservingMap<? extends K, ? extends V> otherHashMap = (OrderPreservingMap<? extends K, ? extends V>)other; final Object[] orderedKeys = otherHashMap.keyArray(); for (int i = 0; i < orderedKeys.length; i++) { this.put((K)orderedKeys[i], (V)other.get(orderedKeys[i])); } } else { for (Entry<? extends K, ? extends V> entry : other.entrySet()) { this.put(entry.getKey(), entry.getValue()); } } }
OrderPreservingMap implements Map<K, V>, Cloneable { @SuppressWarnings("unchecked") public void putAll(Map<? extends K, ? extends V> other) { if (other == null || other.size() == 0) { return; } if (other instanceof OrderPreservingMap) { final OrderPreservingMap<? extends K, ? extends V> otherHashMap = (OrderPreservingMap<? extends K, ? extends V>)other; final Object[] orderedKeys = otherHashMap.keyArray(); for (int i = 0; i < orderedKeys.length; i++) { this.put((K)orderedKeys[i], (V)other.get(orderedKeys[i])); } } else { for (Entry<? extends K, ? extends V> entry : other.entrySet()) { this.put(entry.getKey(), entry.getValue()); } } } }
OrderPreservingMap implements Map<K, V>, Cloneable { @SuppressWarnings("unchecked") public void putAll(Map<? extends K, ? extends V> other) { if (other == null || other.size() == 0) { return; } if (other instanceof OrderPreservingMap) { final OrderPreservingMap<? extends K, ? extends V> otherHashMap = (OrderPreservingMap<? extends K, ? extends V>)other; final Object[] orderedKeys = otherHashMap.keyArray(); for (int i = 0; i < orderedKeys.length; i++) { this.put((K)orderedKeys[i], (V)other.get(orderedKeys[i])); } } else { for (Entry<? extends K, ? extends V> entry : other.entrySet()) { this.put(entry.getKey(), entry.getValue()); } } } OrderPreservingMap(); @SuppressWarnings("unchecked")  OrderPreservingMap(OrderPreservingMap<K, V> other);  OrderPreservingMap(Map<K, V> map, Collection<K> orderedKeys, Collection<V> orderedEntries); }
OrderPreservingMap implements Map<K, V>, Cloneable { @SuppressWarnings("unchecked") public void putAll(Map<? extends K, ? extends V> other) { if (other == null || other.size() == 0) { return; } if (other instanceof OrderPreservingMap) { final OrderPreservingMap<? extends K, ? extends V> otherHashMap = (OrderPreservingMap<? extends K, ? extends V>)other; final Object[] orderedKeys = otherHashMap.keyArray(); for (int i = 0; i < orderedKeys.length; i++) { this.put((K)orderedKeys[i], (V)other.get(orderedKeys[i])); } } else { for (Entry<? extends K, ? extends V> entry : other.entrySet()) { this.put(entry.getKey(), entry.getValue()); } } } OrderPreservingMap(); @SuppressWarnings("unchecked")  OrderPreservingMap(OrderPreservingMap<K, V> other);  OrderPreservingMap(Map<K, V> map, Collection<K> orderedKeys, Collection<V> orderedEntries); @SuppressWarnings("unchecked") Object clone(); @SuppressWarnings("unchecked") void putAll(Map<? extends K, ? extends V> other); void putAll(Collection<Entry<K,V>> entries); V put(K key, V value); V put(K key, V value, int toIndex); Set<K> keySet(); Set<K> keySetReference(); Object[] keyArray(); Collection<K> orderedKeys(); Collection<K> orderedKeysReference(); Set<Map.Entry<K, V>> entrySet(); Set<Map.Entry<K, V>> entrySetReference(); Collection<V> values(); Collection<V> valuesReference(); V get(Object key); V get(int i); K getKey(int index); Collection<V> getAll(Set<K> keys); int indexOfKey(Object key); int indexOf(Object object); boolean containsKey(Object key); boolean containsValue(Object value); boolean containsAll(Collection<V> list); void reverseOrder(); void reorder(Collection<K> keys); void reorder(K[] keys); V remove(Object key); V remove(int index); boolean removeAllKeys(Set<K> keys); void retainAllKeys(Set<K> keys); void clear(); int size(); boolean isEmpty(); V[] toArray(V[] dest); Object[] toArray(); @SuppressWarnings("unchecked") Collection<V> toCollection(); ListIterator<V> listIterator(int index); ListIterator<K> keyListIterator(int index); }
OrderPreservingMap implements Map<K, V>, Cloneable { @SuppressWarnings("unchecked") public void putAll(Map<? extends K, ? extends V> other) { if (other == null || other.size() == 0) { return; } if (other instanceof OrderPreservingMap) { final OrderPreservingMap<? extends K, ? extends V> otherHashMap = (OrderPreservingMap<? extends K, ? extends V>)other; final Object[] orderedKeys = otherHashMap.keyArray(); for (int i = 0; i < orderedKeys.length; i++) { this.put((K)orderedKeys[i], (V)other.get(orderedKeys[i])); } } else { for (Entry<? extends K, ? extends V> entry : other.entrySet()) { this.put(entry.getKey(), entry.getValue()); } } } OrderPreservingMap(); @SuppressWarnings("unchecked")  OrderPreservingMap(OrderPreservingMap<K, V> other);  OrderPreservingMap(Map<K, V> map, Collection<K> orderedKeys, Collection<V> orderedEntries); @SuppressWarnings("unchecked") Object clone(); @SuppressWarnings("unchecked") void putAll(Map<? extends K, ? extends V> other); void putAll(Collection<Entry<K,V>> entries); V put(K key, V value); V put(K key, V value, int toIndex); Set<K> keySet(); Set<K> keySetReference(); Object[] keyArray(); Collection<K> orderedKeys(); Collection<K> orderedKeysReference(); Set<Map.Entry<K, V>> entrySet(); Set<Map.Entry<K, V>> entrySetReference(); Collection<V> values(); Collection<V> valuesReference(); V get(Object key); V get(int i); K getKey(int index); Collection<V> getAll(Set<K> keys); int indexOfKey(Object key); int indexOf(Object object); boolean containsKey(Object key); boolean containsValue(Object value); boolean containsAll(Collection<V> list); void reverseOrder(); void reorder(Collection<K> keys); void reorder(K[] keys); V remove(Object key); V remove(int index); boolean removeAllKeys(Set<K> keys); void retainAllKeys(Set<K> keys); void clear(); int size(); boolean isEmpty(); V[] toArray(V[] dest); Object[] toArray(); @SuppressWarnings("unchecked") Collection<V> toCollection(); ListIterator<V> listIterator(int index); ListIterator<K> keyListIterator(int index);  }