示例#1
0
 public void Append(DLinkedList <T> other)
 {
     Debug.Assert(other != null);
     while (other.Count > 0)
     {
         var first = other.First;
         other.Remove(first);
         AddLast(first);
     }
 }
示例#2
0
        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);
        }
示例#3
0
        /// <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);
        }
示例#4
0
 internal void Invalidate()
 {
     list = null;
     next = null;
     prev = null;
 }
示例#5
0
 internal DLinkedListNode(DLinkedList <T> list, T value)
 {
     this.list  = list;
     this.value = value;
 }