Yes, LinkedList is a doubly linked list, as the Javadoc mentions :
Answer from Eran on Stack OverflowDoubly-linked list implementation of the List and Deque interfaces. Implements all optional list operations, and permits all elements (including null).
All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.
Yes, LinkedList is a doubly linked list, as the Javadoc mentions :
Doubly-linked list implementation of the List and Deque interfaces. Implements all optional list operations, and permits all elements (including null).
All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.
What's missing in java LinkedList is ability to store pointers. Consider the following code:
var list = new LinkedList<Integer>();
var head = list.listIterator();
var anotherHead = list.listIterator();
anotherHead.add(5);
System.out.println(head.next());
We would like to store a pointer to the head and use it later. No way. As soon as the list gets modified (through other pointer for example) our pointer becomes invalid. In a normal linked list the old pointer should still allow us to navigate through the list.
[Java] Implementing an ordered doubly linked list
I can't make the double linked list my assignment is requesting, is this a bad sign for me as a programmer?
Linked List problems : need help to develop an understanding
Doubly linked list using comparable stuck in infinite loop after inserting new node
This is a HW assignment, so if that's discouraged here I can take it over to r/HomeworkHelp, but since this is dedicated to programming I thought I'd get better, faster responses here. Anyway...
So the assignment is to implement a doubly linked DoubleOrderedList class. The assignment states that I need to create three other classes, DoubleNode, DoubleList, DoubleIterator. Googling has led to a few useful results, but most have the structure in one or two classes, and I'm having a hard time understanding how create/use the other classes. Here's what my understanding is.
DoubleOrderedList - main class, and will "use" (i want to say implement, but I'm not sure, on the terminology, is import better?) the other three classes. So no structure definitions, it only contains stuff from the other classes.
DoubleNode - contains methods and data for creating each new node. So this video is my main source, and the beginning sets up what I think my DoubleNode class should be. So here's what came of that
public class DoubleNode<T> {
static int numElements = 0;
private T data;
DoubleNode previous;
DoubleNode next;
public DoubleNode(T data) {
this.data = data;
numElements++;
}}
seems simple enough, this class just defines a single node, and has nothing to do with interacting with any other Nodes yes?
DoubleList - I don't know what to do with this. is this just a basic double linked list? if so then will it implement/import DoubleNode?
DoubleIterator - defines the iterators that will traverse the list. I'm not sure how to create Iterators that will travel back and forward. Will it be only 1 iterator method? If so then it would have to utilize the prev and next references to move around the list right?
any help or references would be appreciated, thanks.