Doubly linked list with head/tail references for int values (Task 1) and a generic LinkedList<T>/ListNode<T> version (Task 2). Both implement add, get, remove, getSize with O(n/2) walks via the closer-end heuristic. Includes IntLinkedListTest covering empty, single-element, head/tail/middle removal, and out-of-bounds cases. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
12 lines
272 B
Java
12 lines
272 B
Java
public class ListNode<T> {
|
|
T value;
|
|
ListNode<T> nextNode;
|
|
ListNode<T> prevNode;
|
|
|
|
public ListNode(T value, ListNode<T> nextNode, ListNode<T> prevNode) {
|
|
this.value = value;
|
|
this.nextNode = nextNode;
|
|
this.prevNode = prevNode;
|
|
}
|
|
}
|