Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinkedList是双向链表不是双向循环链表 #47

Closed
nvkwo3314200 opened this issue Nov 1, 2018 · 2 comments
Closed

LinkedList是双向链表不是双向循环链表 #47

nvkwo3314200 opened this issue Nov 1, 2018 · 2 comments
Labels
enhancement New feature or request or suggestion

Comments

@nvkwo3314200
Copy link

jdk1.8中
/** * Links e as last element. */ void linkLast(E e) { final Node<E> l = last; final Node<E> newNode = new Node<>(l, e, null); last = newNode; if (l == null) first = newNode; else l.next = newNode; size++; modCount++; }
newNode的next并没有指向first而是null

LinkBefore方法中还用pred == null来判断是否插入到第一个node
/** * Inserts element e before non-null Node succ. */ void linkBefore(E e, Node<E> succ) { // assert succ != null; final Node<E> pred = succ.prev; final Node<E> newNode = new Node<>(pred, e, succ); succ.prev = newNode; if (pred == null) first = newNode; else pred.next = newNode; size++; modCount++; }
所以没看出来循环

@freestylefly
Copy link

是@

@Snailclimb
Copy link
Owner

之前没有分清双向链表和双向循环链表 感谢您提出来!

@Snailclimb Snailclimb added the enhancement New feature or request or suggestion label Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request or suggestion
Projects
None yet
Development

No branches or pull requests

3 participants