public void DLLe_Insert_Element_Inside() { // Arrange var list = new DoublyLinkedListExpanded <int>(); // Act list.AddFirst(0); list.InsertAt(1, 0); list.InsertAt(2, 1); // Assert var items = new List <int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List <int>() { 1, 2, 0 }); }
static void Main() { var list = new DoublyLinkedListExpanded <int>(); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.AddLast(5); list.AddFirst(3); list.AddFirst(2); list.AddLast(10); Console.WriteLine("Count = {0}", list.Count); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.RemoveFirst(); list.RemoveLast(); list.RemoveFirst(); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.RemoveLast(); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); Console.WriteLine("2---------2--------2"); list.AddLast(1); list.AddLast(2); list.AddLast(3); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list[0] = 5; list[1] = 6; list[2] = 7; list.AddLast(8); list.AddLast(9); list.AddLast(10); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.InsertAt(20, 3); list.ForEach(Console.WriteLine); Console.WriteLine("3---------3--------3"); Console.WriteLine(list.RemoveAt(4)); Console.WriteLine("--------------------"); list.ForEach(Console.WriteLine); Console.WriteLine("4---------4--------4"); list.Clear(); Console.WriteLine("--------------------"); list.AddLast(8); list.AddLast(9); list.AddLast(10); }