我想知道在SparseArray类的HashMap类上是否有与 putAll 方法相同的方法?
我很困惑,如果我应该使用追加, put 或 setValueAt ,如果它会给我相同的结果。
是SparseArrayX.append(i,SparseArrayY.valueAt(i))= MapX.put(MapY); ?
答案 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.