Class CircularDLinkedList<X>
java.lang.Object
Jcg.util.CircularDLinkedList<X>
Minimal implementation of a circular doubly linked list, storing generic type elements
- Author:
- Luca Castelli Aleardi (Ecole Polytechnique, 2021-2024)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCircularDLinkedList(DLinkedList<X> list) Create a circular linked list from a doubly linked list (not circular). -
Method Summary
Modifier and TypeMethodDescriptionclone()Create a clone (a copy) of a circular doubly linked list.booleancontainsNode(DListNode<X> node) Check whether the circular list contains a given node (check reference equality)
Remark: useful for debuggingvoidRemove a given node from the listgetFirst()Return the first node of the list The result is a null reference if the list is emptyvoidinsertAfter(DListNode<X> pNode, X el) Insert a new element after a given node in the listvoidinsertBefore(DListNode<X> pNode, X el) Insert a new element before a given node in the listbooleanisEmpty()Check whether the list is emptystatic voidintsize()toString()Return a String representing the list
-
Field Details
-
first
-
size
private int sizenumber of nodes in the list
-
-
Constructor Details
-
CircularDLinkedList
Create a circular linked list from a doubly linked list (not circular).
Warning: the input 'list' is modified.
-
-
Method Details
-
clone
Create a clone (a copy) of a circular doubly linked list.
Remark: the two lists shared the elements, but the nodes are different.
The original (current) list is not modified. -
size
public int size() -
isEmpty
public boolean isEmpty()Check whether the list is empty -
getFirst
-
insertAfter
-
insertBefore
-
delete
-
toString
-
containsNode
-
main
-