android Google推荐的容器SparseArrayCompat简介
android Google推荐的容器SparseArrayCompat简介private static SparseArrayCompat<BaseFragment>mCaches = new SparseArrayCompat<BaseFragment>();mCaches.put(xx);mCaches.get(xx);优点节省最高50%缓存;SparseArrayCompat(
·
android Google推荐的容器SparseArrayCompat简介
private static SparseArrayCompat<BaseFragment> mCaches = new SparseArrayCompat<BaseFragment>();
mCaches.put(xx);
mCaches.get(xx);
- 优点节省最高50%缓存;
SparseArrayCompat()其实是一个map容器,它使用了一套算法优化了hashMap,可以节省至少50%的缓存. - 缺点但是有局限性只针对下面类型.
- key: Integer; value: object
因此当HshMap()的key是Integer类型时推荐使用SparseArrayCompat(),用法与Map相似.
如下格式:
private static HashMap<Integer, Fragment> mCaches = new HashMap<Integer, Fragment>();
更多推荐
已为社区贡献1条内容
所有评论(0)