美文网首页
Android之LinkList

Android之LinkList

作者: 福later | 来源:发表于2019-12-12 11:54 被阅读0次
public class LinkedList<E>
    extends AbstractSequentialList<E>
    implements List<E>, Deque<E>, Cloneable, java.io.Serializable
{
}

可以和ArrayList实现对比下Android之ArrayList
ArrayList 实现多了一个AccessRondom 接口,少了Deque 接口
LinkList 实现多了Deque接口,少了AccessRandom接口
想了解AccessRandom接口可以参看AccessRandom接口有啥用
Deque接口顾名思义,队列,说明LinkList 支持队列操作
来看看内部属性

transient int size = 0;

    /**
     * Pointer to first node.
     * Invariant: (first == null && last == null) ||
     *            (first.prev == null && first.item != null)
     */
    transient Node<E> first;

    /**
     * Pointer to last node.
     * Invariant: (first == null && last == null) ||
     *            (last.next == null && last.item != null)
     */
    transient Node<E> last;

    /**
     * Constructs an empty list.
     */
    public LinkedList() {
    }

    /**
     * Constructs a list containing the elements of the specified
     * collection, in the order they are returned by the collection's
     * iterator.
     *
     * @param  c the collection whose elements are to be placed into this list
     * @throws NullPointerException if the specified collection is null
     */
    public LinkedList(Collection<? extends E> c) {
        this();
        addAll(c);
    }

官方文档对LinkList 的解释是双向链表,那么很容易理解这里保留first ,last 指针的意义了,就是为了方便双向遍历和插入
本身添删改查没有太多要说,注意下按索引遍历,先是算下inde与size /2 比较下,然后决定是从头部开始遍历还是尾部开始遍历。

相关文章

  • Android之LinkList

    可以和ArrayList实现对比下Android之ArrayListArrayList 实现多了一个AccessR...

  • 链表(C语言)

    LinkList.h LinkList.c

  • 单链表

    LinkList.h typedef void LinkList;typedef void LinkListNod...

  • 线性表--链表(C++)

    Node.h Node.cpp LinkList.h LinkList.cpp test.cpp

  • JavaSE基础知识学习-----集合之LinkList

    LinkList 概述 LinkList是List接口的实现类,与ArrayList不同的是,ArrayList采...

  • 链表,单链表

    关于链表的一些知识 ifndef LINKLIST_H define LINKLIST_H typedef voi...

  • linklist

    LinkedList 是一个类 实现的接口:List、Collection、Iterable、Seriali...

  • linkList

    有时觉得链表的首节点和其他节点导致的不同环境使代码非常复杂的,可以考虑在链表头处加一个dummy node, 这样...

  • Linklist

    大家好,我是IT修真院,一枚正直纯洁善良的如刚入门的Java程序员,今天试着给大家分享一下关于Linklist的内...

  • LinkList

    前言 在看了ArrayList 发现LinkList跟ArrayList的构造很相似 只不过在添加的时候换成了游标...

网友评论

      本文标题:Android之LinkList

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