美文网首页
JAVA非并发容器--ArrayList, LinkedList

JAVA非并发容器--ArrayList, LinkedList

作者: 小犇手K线研究员 | 来源:发表于2017-03-16 23:32 被阅读16次

    概述

    java-list.png

    ArrayList底层数据是数组, LinkedList的数据结构是双向链表, 节点数据结构如下:

    private static class Node<E> {
            E item;
            Node<E> next;
            Node<E> prev;
    
            Node(Node<E> prev, E element, Node<E> next) {
                this.item = element;
                this.next = next;
                this.prev = prev;
            }
        }
    

    迭代器

    List有迭代器ListIterator, 相比与Iterator, 其可以双向遍历,既可以向前遍历也可以向后遍历.
    其方法如下:


    ListIterator.png

    相关文章

      网友评论

          本文标题:JAVA非并发容器--ArrayList, LinkedList

          本文链接:https://www.haomeiwen.com/subject/ysysnttx.html