public void Add(T item) { if (Head == null) { Head = new DoublyLinkedListNode <T>(item, null, null); } else { DoublyLinkedListNode <T> node = Head; //loop until last node while (node != null) { node = node.Next; } //or //for(; node.Next != null; node = node.Next){} node.Next = new DoublyLinkedListNode <T>(item, null, null); } _size++; }
public DoublyLinkedListNode(T data, DoublyLinkedListNode <T> prev, DoublyLinkedListNode <T> next) { this.Data = data; this.Prev = prev; this.Next = next; }
public DoublyLinkedListNode() { this.Data = default(T); this.Prev = null; this.Next = null; }