fromList<T> static method
Creates a doubly linked list from a list of values
values - List of values to convert to a doubly linked list
Returns the head of the created doubly linked list
Implementation
static DoublyLinkedListNode<T>? fromList<T>(List<T> values) {
if (values.isEmpty) return null;
DoublyLinkedListNode<T> head = DoublyLinkedListNode<T>(values[0]);
DoublyLinkedListNode<T> current = head;
for (int i = 1; i < values.length; i++) {
DoublyLinkedListNode<T> newNode = DoublyLinkedListNode<T>(values[i]);
current.next = newNode;
newNode.prev = current;
current = newNode;
}
return head;
}