HashMap和SparseArray可以实现相似的功能。

但SparseArray是Android定义的,在键是整数时,他比HashMap的性能更高,因为HashMap使用的是Integer对象,

而SparseArray使用的是int型,因此使用HashMap会创建很多的Integer对象,而使用SparseArray则可以避免。

 

 

所以有时候用来缓存bitmap的时候,能用SparseArray就用SparseArray,它的性能更好一点。

相关文章:

  • 2022-02-10
  • 2022-12-23
  • 2021-11-28
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2022-02-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
  • 2022-02-08
  • 2021-12-03
相关资源
相似解决方案