Exemple #1
0
        /// <summary>
        /// method to make a linked list, print to screen, and find a selected value
        /// </summary>
        static void MakeLL()
        {
            LinkList LL = new LinkList(new Node(10));

            Node LL1 = new Node(15);
            Node LL2 = new Node(20);
            Node LL3 = new Node(25);

            LL.Add(LL1);
            LL.Add(LL2);
            LL.Add(LL3);

            LL.Print();

            Node addMeBefore = new Node(1);
            Node addMeAfter  = new Node(2);

            LL.Find(25);

            LL.AddBefore(addMeBefore, LL3);
            LL.AddAfter(addMeAfter, LL2);

            LL.Print();
            //expected output 1-- 25 -- 20 -- 2 -- 15 -- 10
        }
Exemple #2
0
        static void TestLL()
        {
            LinkList list = new LinkList(new Node(5));

            list.Add(new Node(10));
            list.Add(new Node(25));
            list.Add(new Node(50));
            list.Print();

            Node found = list.Find(10);

            Console.WriteLine($"Node value found: {found.Value}");

            Console.WriteLine($"Let's add a node before {found.Value}");
            list.AddBefore(new Node(26), found);
            list.Print();
            Console.WriteLine("-----");

            Console.WriteLine($"Let's add a node after {found.Value}");
            Console.WriteLine($"Node value found: {found.Value}");
            list.AddAfter(new Node(30), found);
            list.Print();
            Console.WriteLine("-----");

            Console.WriteLine("Lets add a node at the end");
            list.AddLast(new Node(1));
            list.Print();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            LinkList ll = new LinkList(1);

            ll.AddLast(2);
            ll.AddFirst(3);
            ll.AddBefore(5, 2);
        }