public void Append(DLinkedList <T> other) { Debug.Assert(other != null); while (other.Count > 0) { var first = other.First; other.Remove(first); AddLast(first); } }
public DLinkedList <T> Duplicate() { var result = new DLinkedList <T>(); foreach (var v in this) { var n = new DLinkedListNode <T>(v); result.AddLast(n); } return(result); }
/// <summary> /// Make sublist from give index, and up to size /// </summary> /// <param name="index"></param> /// <param name="size">if -1 then up to end of list</param> /// <returns></returns> public DLinkedList <T> DuplicateReverse(int index, int size) { Debug.Assert(index >= 0); Debug.Assert(index < Count); Debug.Assert(index + size < Count); var result = new DLinkedList <T>(); var current = GetNodeAtIndex(index); while (current != null && (size < 0 || size > 0)) { var n = new DLinkedListNode <T>(current.Value); result.AddFirst(n); size--; current = current.Next; } return(result); }
internal void Invalidate() { list = null; next = null; prev = null; }
internal DLinkedListNode(DLinkedList <T> list, T value) { this.list = list; this.value = value; }