public T this[int index] { get { return(GetCurrentNode(index).Value); } set { if ((index >= 0) && (index < Length)) { DLNode <T> current = _root; for (int i = 1; i <= index; i++) { current = current.Next; } current.Value = value; } else { throw new IndexOutOfRangeException(); } } }
public DLinkedList(T[] values) { if (!(values is null)) { Length = values.Length; if (values.Length != 0) { _root = new DLNode <T>(values[0]); _tail = _root; for (int i = 1; i < values.Length; i++) { _tail.Next = new DLNode <T>(values[i]); _tail.Next.Previous = _tail; _tail = _tail.Next; } } else { _root = null; _tail = null; } }
public DLNode(T value) { Value = value; Next = null; Previous = null; }
public DLinkedList(T value) { Length = 1; _root = new DLNode <T>(value); _tail = _root; }
public DLinkedList() { Length = 0; _root = null; _tail = null; }