Exemplo n.º 1
0
 static void Main(string[] args)
 {
     DoublyLinkedList test = new DoublyLinkedList();
     test.InsertAt(0, 1);
     test.InsertAt(1, 2);
     test.Add(3);
     Console.WriteLine("List elements:");
     test.Print();
     test.RemoveAt(0);
     Console.WriteLine("List elements after removing element at index 0:");
     test.Print();
     test.InsertAt(2, 4);
     Console.WriteLine("List elements after inserting an element at index 2(after the last element):");
     test.Print();
     Console.WriteLine("List elements after changing element data at index 1 with '5':");
     test.ChangeDataAtIndex(1, 5);
     test.Print();
     Console.WriteLine("List elements after changing element with value '2' to '3':");
     test.ChangeElementData(2, 3);
     test.Print();
     Console.WriteLine("List elements after removing element with value '4'");
     test.Remove(4);
     test.Print();
     object element = test.GetElementData(1);
     Console.WriteLine("Value of element at index 1:" + element);
     Console.WriteLine("Index of element with value 3:{0}", test.IndexOf(3));
     Console.WriteLine("List contains element with value = '5': {0}", (test.Contains(5)) ? "Yes" : "No");
     Console.WriteLine("Is list empty? - {0}", (test.IsEmpty) ? "Yes" : "No");
 }