SparseArray上putAll的等效方法

时间:2016-01-12 12:43:00

标签: java android data-structures hashmap sparse-matrix

我想知道在SparseArray类的HashMap类上是否有与 putAll 方法相同的方法?

我很困惑,如果我应该使用追加 put setValueAt ,如果它会给我相同的结果。

是SparseArrayX.append(i,SparseArrayY.valueAt(i))= MapX.put(MapY); ?

1 个答案:

答案 0 :(得分:2)

SparseArray类没有可用的putAll()方法。 Android Docs

append(int key, E value)
Puts a key/value pair into the array, optimizing for the case where the key is greater than all existing keys in the array.

put(int key, E value)
Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one.

setValueAt(int index, E value)
Given an index in the range 0...size()-1, sets a new value for the indexth key-value mapping that this SparseArray stores.