LinkedList是双向循环链表吗

wangbiao007 2016-09-12 03:56:27
今天看LinkedList源码,发现JDK1.7中LinkedList源码和以前的LinkedList源码有很大区别,JDK1.7中的LinkedList源码没有了header这个属性,再查看源码的时候,发现LinedList好像不是双向循环链表,看以前的源码,感觉LinedList是双向循环链表。这里想向大家确认一下LinedList是否是双向循环链表,注意:我想确认的是在“循环”二字上。
下面是JDK1.7的LinkedeList源码
/**
* Inserts the specified element at the beginning of this list.
*
* @param e the element to add
*/
public void addFirst(E e) {
linkFirst(e);
}




/**
* Links e as first element.
*/
private void linkFirst(E e) {
final Node<E> f = first;
final Node<E> newNode = new Node<>(null, e, f);
first = newNode;
if (f == null)
last = newNode;
else
f.prev = newNode;
size++;
modCount++;
}


 /**
* 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;
...全文
1606 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
我去个地方 2018-03-17
  • 打赏
  • 举报
回复 3
jdk1.6是双向循环链表,jdk1.7之后就变成了双向链表,去掉了head
爬楼梯的小怪 2017-08-16
  • 打赏
  • 举报
回复
今天看了看源码的时候也发现了这样的问题,还在纳闷为什么搜出来的结果都是循环链表,而我看的不是,后来发现之前的源码和之后的区别很大,LinkedList也从循环链表换成非循链表
家里敷泥呀 2016-09-12
  • 打赏
  • 举报
回复
接分器。。。。
wangbiao007 2016-09-12
  • 打赏
  • 举报
回复
我现在看懂了,至少在JDK1.7中,LinkedList不是双向循环链表,而是双向链表

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧