双向链表结构,查询慢,增删快线程不安全 linkedList分点详解 linkedList继承实现情况
linkedList数据结构- 链表节点类型为内部类
private static class Node{ E item; Node next; Node prev; Node(Node prev, E element, Node next) { this.item = element; this.next = next; this.prev = prev; } }
- 默认新增数据就是直接在链表终端添加元素
//1.添加元素
public boolean add(E e) {
linkLast(e);
return true;
}
//2.在链表末尾添加元素
void linkLast(E e) {
//链表末节点
final Node l = last;
//新节点
final Node newNode = new Node<>(l, e, null);
//链表末位节点更新
last = newNode;
if (l == null)
first = newNode;
else
l.next = newNode;
size++;
modCount++;
}



