Is java doubly linked list circular ?
It nowhere written in java docs. But looks likes its circular when i see linked list source code Here is the relevant code snippet if
private Entry<E> More ...entry(int index) {
...
Entry<E> e = header;
if (index < (size >> 1)) {
...
} else {
for (int i = size; i > index; i--)
e = e.previous;
}
return e;
}
Update :- By circular i mean
Going by your criteria
- header previous node should be last node which seems true here
- And for last node next node should be header node
Linked list is circular because if you see add
method implementation which internally calls addBefore
, entry you going to insert points to header as next link and header points to last entry you just inserted as previous link
It's not circular. It has a clear Head and Tail.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.