LongSparseArray implements Cloneable { public void putAll(@NonNull LongSparseArray<? extends E> other) { for (int i = 0, size = other.size(); i < size; i++) { put(other.keyAt(i), other.valueAt(i)); } } LongSparseArray();  LongSparseArray(int initialCapacity); @Override @SuppressWarnings("unchecked") LongSparseArray<E> clone(); @Nullable @SuppressWarnings("NullAway") // See inline comment. E get(long key); @SuppressWarnings("unchecked") E get(long key, E valueIfKeyNotFound); @Deprecated void delete(long key); void remove(long key); boolean remove(long key, Object value); void removeAt(int index); @Nullable E replace(long key, E value); boolean replace(long key, E oldValue, E newValue); void put(long key, E value); void putAll(@NonNull LongSparseArray<? extends E> other); @Nullable E putIfAbsent(long key, E value); int size(); boolean isEmpty(); long keyAt(int index); @SuppressWarnings("unchecked") E valueAt(int index); void setValueAt(int index, E value); int indexOfKey(long key); int indexOfValue(E value); boolean containsKey(long key); boolean containsValue(E value); void clear(); void append(long key, E value); @Override String toString();  }
@Test public void putAll() { LongSparseArray<String> dest = new LongSparseArray<>(); dest.put(1L, "one"); dest.put(3L, "three"); LongSparseArray<String> source = new LongSparseArray<>(); source.put(1L, "uno"); source.put(2L, "dos"); dest.putAll(source); assertEquals(3, dest.size()); assertEquals("uno", dest.get(1L)); assertEquals("dos", dest.get(2L)); assertEquals("three", dest.get(3L)); }