List:
a List is an ordered collection, and unlike a set, the list typically allow duplicate elements.
ArrayList
1.内部通过数组实现,允许对元素进行快速随机访问,缺点是每个元素之间不能有间隔,需要有一个连续的内存空间,当capacity不足够时,需要将已有的数据复制到新的存储空间中。
2.当从ArrayList中间位置插入或者删除元素时,需要对数组进行复制和移动,代价较高。所以它适合查找和遍历,不适合插入和删除。
3.复制时调用 System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
4.Increase the capacity of the ArrayList instance,if necessary when adding an element to the arraylist:
newCapacity = (oldCapacity * 3)/2 + 1;
5.The attribute Size and Capacity are of different concepts.
LinkedList
entry(int i): return the indexed entry
通过(index < (size >> 1)) 将size 右移一位,高位补0,相当于size/2,来决定通过e.previous还是e.next来 遍历链表。将时间复杂度降低到O(n/2)
2.LinkedList遍历和访问较慢。
3.双向链表,提供了除了List接口之外的用于操作表头和表尾的方法,可用于实现为堆栈、队列、双向链表。
Vector:
1.与ArrayList一样,同样基于数组实现。
2.支持线程同步,即某一时刻只有一个线程可以访问Vector。
3.实现同步需要较高性能开销,访问比ArrayList慢。