1.SparseArray 类似 HashMap Key :Int value object
用法:
private SparseArray<Object> mUserListMap = new SparseArray<>();
mUserListMap.append(int,Object);
Object object = mUserListMap.get(int i);
2.LongSparseArray 类似 HashMap Key ;long value:object
用法:
LongSparseArray<Object> mStoryLongSparseArray = new LongSparseArray<>();
mStoryLongSparseArray.append(Long, Object);
Object object = mStoryLongSparseArray.get(Long long);
IntArray 只存放 intent
用法:
3.IntArray array = new IntArray();
if (!array.contains(userId)) { array.add(userId); }
if (array.size == 0) { return; }
array.toArray())
4.ArraySet 可以存放 String 且唯一 经常用做 去重逻辑
用法:
ArraySet<String> messageHashMap = new ArraySet<>();
synchronized (messageHashMap) { if (!messageHashMap.add("String")) { messageHashMap.remove("String"); return; } }