Updated Doubly linked list to allow for the combining of 2 lists
This commit is contained in:
		@@ -28,6 +28,30 @@ namespace C_.Datastructures
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public static DoublyLinkedList<T> Create(DoublyLinkedList<T> list1, DoublyLinkedList<T> list2)
 | 
			
		||||
        {
 | 
			
		||||
            //Create a new list from 2 separate lists
 | 
			
		||||
            
 | 
			
		||||
            DoublyLinkedList<T> list;
 | 
			
		||||
 | 
			
		||||
            list = list1;
 | 
			
		||||
            if (list == null || list.Count == 0) return list2;
 | 
			
		||||
 | 
			
		||||
            //Find end of list and append fist item of next list
 | 
			
		||||
            if (list2 == null || list.Count == 0) return list;
 | 
			
		||||
 | 
			
		||||
            DoublyLinkedListNode<T>? end = list.Traverse();
 | 
			
		||||
 | 
			
		||||
            //Connect up pointers at ajoining section
 | 
			
		||||
            end!.Next = list2!.Head;
 | 
			
		||||
            end!.Next!.Prev = end;
 | 
			
		||||
            end = list2.Tail;
 | 
			
		||||
            list.Count += list2!.Count;
 | 
			
		||||
 | 
			
		||||
            return list;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public T? this[int i]
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user