一、类图关系

       AbstractSequentialList 与 LinkedList

二、要点记录

1.  AbstractSequentialList 继承自 AbstractList,是 AbstractList 其中一类(RandomAccess)的对立面

     也就是说,AbstractSequentialList 不是 RandomAccess 的,是顺序访问的

2.  LinkedList 不止实现了 List 接口,而且实现了 Deque 接口,

     在结构上,它是双向链表(内置了 Node 定义),兼顾双端队列、栈的操作

3.  LinkedList 非线程安全

4.  迭代器 fail-fast

5.  LinkedList 查找时,根据下标大小与 size/2 的关系,自动选择查找方向

    Node<E> node(int index) {
        // assert isElementIndex(index);

        if (index < (size >> 1)) {
            Node<E> x = first;
            for (int i = 0; i < index; i++)
                x = x.next;
            return x;
        } else {
            Node<E> x = last;
            for (int i = size - 1; i > index; i--)
                x = x.prev;
            return x;
        }
    }

6.   有一个逆序迭代器 

    /**
     * @since 1.6
     */
    public Iterator<E> descendingIterator() {
        return new DescendingIterator();
    } 

7.  查询情况多,使用 ArrayList,增减情况多,使用 LinkedList

相关文章:

  • 2021-10-22
  • 2021-06-16
  • 2021-06-28
  • 2021-11-01
  • 2021-05-01
猜你喜欢
  • 2021-11-18
  • 2021-07-04
  • 2021-12-05
  • 2021-12-22
  • 2021-05-12
  • 2021-11-02
相关资源
相似解决方案