A circular linked list can have only one reference direction (as with the linked list) or a double reference as with the doubly linked list. The only difference between the circular linked list and a linked list is that the last element's next (tail.next
) pointer does not make a reference to null
, but to the first element (head
), as we can see in the following diagram:
A doubly circular linked list has tail.next
pointing to the head
element, and head.prev
pointing to the tail
element:
Note
We will not cover the CircularLinkedList
algorithm in this book (the source code is very similar to LinkedList
and DoublyLinkedList
). However, you can access the code by downloading this book's source code. Inside the book's source code you will also find the ECMAScript 6 version of all the three linked list classes.