Exemplo n.º 1
0
        static void Main(string[] args)
        {
            DoublyLinkedList list = new DoublyLinkedList();
            Console.WriteLine("Insert 1, 2, 3, 4");
            list.Insert(1);
            list.Insert(2);
            list.Insert(3);
            list.Insert(4);
            list.Print();

            list.InsertAt(0, 77);
            list.InsertAt(4, 77);
            list.Print();

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            DoublyLinkedList list = new DoublyLinkedList();

            Console.WriteLine("Insert 1, 2, 3, 4");
            list.Insert(1);
            list.Insert(2);
            list.Insert(3);
            list.Insert(4);
            list.Print();

            list.InsertAt(0, 77);
            list.InsertAt(4, 77);
            list.Print();

            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            DoublyLinkedList myDList = new DoublyLinkedList();

            myDList.InsertFront(myDList, 24);
            myDList.InsertLast(myDList, 4);
            myDList.InsertLast(myDList, 91);
            myDList.InsertLast(myDList, 32);
            myDList.InsertFront(myDList, 1222);
            myDList.DeleteNodebyKey(myDList, 4);
            myDList.Print();
            Console.Read();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            //Create Linked list
            var dll = new DoublyLinkedList <int>(7);

            dll.Print();

            //Push 1 at the beginning of the list
            dll.Push(1);

            //Push 2 at the beginning of the list
            dll.Push(2);

            //Push 4 after Head.Next
            var four = dll.InsertAfter(dll.Head.Next, 4);

            //Push 5 before 1
            dll.InsertBefore(dll.Head.Next, 5);

            //Append 9
            var nine = dll.Append(9);

            //Deletes 2 and makes 1 Head
            dll.Delete(dll.Head);

            //Delete 9
            dll.Delete(nine);

            //Delete 4
            dll.Delete(four);

            Console.ReadLine();

            dll.Print();
            //Finish program
            Console.ReadLine();
        }
Exemplo n.º 5
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");
 }