ArrayList 数组
-
add 后边元素都要移动一位,Array copy
-
remove 也是同样的操作,Array copy 慢
-
query 速度快,根据下标直接找到;
-
支持 null
LinkedList 双向链表
-
add 在链表结尾增加一个节点;速度快
-
remove 需要遍历 慢
-
query 需要遍历 慢
-
支持 null
SparseArray 数组+二分查找
- Keys 数组
- Values 数组
- put 需要排序 二分排序
- 跟 key 有关的使用 二分搜索
- query value 遍历
- remove 需要排序
HashSet HashMap
- Key -> HashCode
- HashCode -> index ; h & (length-1) = h%length
- 插入链表头;
hashtable + 链表