-
参考
(1)SparseArray:
https://developer.android.com/reference/android/util/SparseArray
(2)Android内存优化(使用SparseArray和ArrayMap代替HashMap)
https://blog.csdn.net/u010687392/article/details/47809295
(3) SparseArray 的使用及实现原理
https://juejin.cn/post/6844903442901630983 -
为什么使用SparseArray替换HashMap
SparseArray is intended to be more memory-efficient than a HashMap,
because it avoids auto-boxing keys
and its data structure doesn't rely on an extra entry object for each mapping.
为了去获取更高效的内存利用.
SparseArray避免了key从int 自动装箱为Interger类型,直接使用了int数组.
SparseArray不像HashMap一样依赖额外的数据结构Entry去存储<K, V>;
而是直接分别用了key,和value两个数组.