public static void Main(string[] args)
        {
            Node node1 = new Node(7);
            Node node2 = new Node("node2");
            Node node3 = new Node("node3");

            LList List = new LList(node1);

            List.Add(node2);
            List.Add(node3);

            Console.WriteLine("======= Original List =======");
            List.Print();

            Console.WriteLine("======= Node Appended to the End =======");
            Node node4 = new Node("node4");

            List.Append(node4);
            List.Print();

            Console.WriteLine("======= Node Added Before Node 4 =======");
            Node node5 = new Node("node5");

            List.AddBefore(node5, node4);
            List.Print();

            Console.WriteLine("======= Node Added After Node 5 =======");
            Node node6 = new Node("node6");

            List.AddAfter(node6, node5);
            List.Print();
        }
        static void NodeTraverse()
        {
            LList list = new LList();

            list.Insert(6);
            list.Insert(8);
            list.Insert(12);

            Console.WriteLine($" does 8 exist: {list.Includes(8)}");
            Console.WriteLine($" does 6 exist: {list.Includes(6)}");
            Console.WriteLine($" does 12 exist: {list.Includes(8)}");

            list.Print();

            list.Append(16);
            list.Append(25);
            list.Append(30);

            Console.WriteLine($" does 30 exist: {list.Includes(30)}");


            list.InsertBefore(25, 53);
            list.InsertAfter(53, 31);

            list.Print();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");


            LList list = new LList();

            list.Insert(2);
            list.Insert(4);
            list.Insert(6);
            list.Insert(7);
            list.Insert(79);
            list.print();
            list.InsertAfter(6, 88);
            list.print();
            list.InsertBefore(6, 48);
            list.Append(43);
            list.print();
            Console.WriteLine("...............");
            int a = list.GetValue(9);
            int b = list.GetValue(0);
            int c = list.GetValue(4);

            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.WriteLine(c);
        }
        static void Main(string[] args)
        {
            LList list = new LList();

            list.InsertAfter(2, 5);
            list.Print();
            Console.ReadLine();
        }
示例#5
0
        static void Main(string[] args)
        {
            LList list = new LList();

            for (int i = 0; i < 15; i++)
            {
                list.Insert(i + 1);
            }
            Console.WriteLine(list.Print());
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            LList testLL = new LList(new Node(4));

            testLL.Append(new Node(21));
            Node newNode = new Node(5);

            testLL.AddBefore(newNode, 21);

            Console.WriteLine($"{testLL.Head.Value}");
        }
示例#7
0
        static void Main(string[] args)
        {
            LList list = new LList();

            list.Insert(4);
            list.Insert(8);
            list.Insert(15);
            list.Insert(23);
            list.Insert(21);

            Console.WriteLine(PosFrmEnd(list.Head, 3));
        }
示例#8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Node node1 = new Node(7);
            Node node2 = new Node("cat");
            Node node3 = new Node(234);

            LList myAwesomeList = new LList(node1);

            myAwesomeList.Append(node2);

            myAwesomeList.Print();
        }
        static void Main(string[] args)
        {
            LList  list = new LList();
            Random rand = new Random();

            list.Insert(23);
            for (int i = 0; i < 10; i++)
            {
                if (i == 6)
                {
                    list.Insert(777);
                }

                list.Insert(rand.Next(50));
            }

            Console.WriteLine("The random link list was created.");

            Console.WriteLine($"\n\nThe list has a node containing 10: { list.Includes(10) }");
            Console.WriteLine($"The list has a node containing 23: { list.Includes(23) }");
            Console.WriteLine($"The list has a node containing 48: { list.Includes(48) }");

            Console.WriteLine("\n-------------------------------------------------------------------\n");
            Console.WriteLine("Here is the linked list: ");
            Console.WriteLine(list.Print());

            Console.WriteLine("\n-------------------------------------------------------------------\n");
            Console.WriteLine("Inserted a random number before 777");
            list.InsertBefore(777, rand.Next(50));
            Console.WriteLine("Here is the updated list\n");
            Console.WriteLine(list.Print());

            Console.WriteLine("\n-------------------------------------------------------------------\n");
            Console.WriteLine("Inserted a random number after 777");
            list.InsertAfter(777, rand.Next(50));
            Console.WriteLine("Here is the updated list\n");
            Console.WriteLine(list.Print());

            Console.WriteLine("\n-------------------------------------------------------------------\n");
            list.Append(rand.Next(50));
            Console.WriteLine("Appended a random number to the end of the list");
            Console.WriteLine("Here is the updated list\n");
            Console.WriteLine(list.Print());



            Console.Write("\n\nPress any key to continue...");
            Console.ReadLine();
        }
        /// <summary>
        /// Thhis is where the program starts
        /// </summary>
        static void startNode()
        {
            try
            {
                LList carlosList = new LList();
                Console.WriteLine("");
                Console.WriteLine("Starting with empty node");
                carlosList.Print();

                carlosList.Insert(77);
                carlosList.Insert(66);
                carlosList.Insert(55);
                carlosList.Insert(44);
                carlosList.Insert(33);
                Console.WriteLine("");
                Console.WriteLine("Linked List with Insert numbers 77,66,55,44.");
                carlosList.Print();

                Console.WriteLine("");
                Console.WriteLine($"Does 66 exsist {carlosList.Includes(66)}");
                Console.WriteLine($"Does 12 exsist {carlosList.Includes(12)}");

                carlosList.Append(88);
                carlosList.Append(99);
                Console.WriteLine("");
                Console.WriteLine("The appended linked list.  Appended 88,99.");
                carlosList.Print();

                carlosList.InsertBefore(66, 61);
                carlosList.InsertBefore(33, 31);
                Console.WriteLine("");
                Console.WriteLine("The InsertBefore Linked List.  Insert before 66, newValue 61.");
                Console.WriteLine("The InsertBefore Linked List.  Insert before 33, newValue 31."); //head of LL
                carlosList.Print();

                carlosList.InsertAfter(44, 49);
                carlosList.InsertAfter(31, 32);
                Console.WriteLine("");
                Console.WriteLine("The InsertAfter Linked List.  Insert after 44, newValue 49.");
                Console.WriteLine("The InsertAfter Linked List.  Insert after 31, newValue 32."); //head of LL
                carlosList.Print();

                Console.ReadLine();
            }
            catch (Exception error)
            {
                Console.WriteLine($"Oh no.  Error {error.Message}!!");
            }
        }
示例#11
0
        static void PopulateList()
        {
            LList list = new LList(11);

            list.Insert(56);
            list.Insert(42);
            list.Insert(23);
            list.Insert(72);
            list.Insert(11);
            list.InsertBefore(42, 7);

            list.Print();

            Console.ReadLine();
        }
示例#12
0
        static void Main(string[] args)
        {
            LList <double> list = new LList <double>();

            list.Push(-11.5);
            list.Enqueue(1);
            list.Enqueue(5);
            list.Enqueue(-2);
            list.Push(55.8);
            list.Enqueue(0);
            list.Enqueue(10);
            list.Push(12);

            Console.WriteLine(list.ToString());
        }
示例#13
0
        static void Main(string[] args)
        {
            var n = new LList <string>();

            n.Add("1");
            n.Add("2");
            n.Add("3");
            n.Add("4");
            n.Add("5");
            Console.WriteLine(n.Count());
            n.RemoveAt(3);
            Console.WriteLine(n.Count());
            foreach (var item in n)
            {
                Console.WriteLine(item);
            }

            //    Console.WriteLine(n.Next.Next.Data);
        }
示例#14
0
        static void LinkedList()
        {
            LList <int> list = new LList <int>();

            list.Insert(8);
            list.Insert(4);
            list.Insert(15);

            Console.WriteLine("==============");
            Console.WriteLine(string.Join(',', list.Print()));


            LList <string> stringList = new LList <string>();

            stringList.Insert("cat");
            stringList.Insert("dog");
            stringList.Insert("bird");

            Console.WriteLine("STRINGS!");
            Console.WriteLine(string.Join(',', stringList.Print()));

            LList <Node <int> > nodeList = new LList <Node <int> >();



            //list.Print();
            //Console.WriteLine(list.Includes(55));

            //list.Append(16);

            //list.Print();

            //list.InsertBefore(16, 15);

            //list.Print();

            //list.InsertAfter(16, 23);
            //list.InsertAfter(4, 5);

            //list.Print();
        }
示例#15
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            LList testLL = new LList(new Node(4));

            testLL.Append(new Node(21));
            Node newNode = new Node(5);

            testLL.AddBefore(newNode, 21);

            testLL.Print();



            int value = testLL.KthFromEnd(1);

            Console.WriteLine(value);
            Console.ReadKey();

            Console.WriteLine($"{testLL.Head.Value}");
        }
示例#16
0
        static void Main(string[] args)
        {
            LList examList = new LList();

            examList.Add(3);
            Console.WriteLine("Added 3");
            examList.Add(5);
            Console.WriteLine("Added 5");
            examList.Add(4);
            Console.WriteLine("Added 4");
            examList.Add(10);
            Console.WriteLine("Added 10");
            examList.Add(7);
            Console.WriteLine("Added 7");
            examList.Add(2);
            Console.WriteLine("Added 2");
            examList.Delete(1);
            Console.WriteLine("Deleted value at index 1");
            Console.WriteLine("Retrieving value at index 1 : " + examList.Retrieve(1));
            Console.WriteLine("Merging values at indexes 2 and 4 : " + examList.Merge(2, 4));
            Console.ReadLine();
        }
        /*
         * Console.WriteLine("Hello World!");
         * //instantiate a new list
         * LList list = new LList();
         * //using these values
         * int[] arrayofValues = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
         * for (int i =0; i < arrayofValues.Length; i++)
         * {
         *  list.Insert(arrayofValues[i]);
         * }*/

        static void NodeExample()
        {
            Node node = new Node(8);

            Console.WriteLine(node.Value);
            LList list = new LList();

            list.Insert(4);
            list.Insert(8);
            list.Insert(15);

            Console.WriteLine($"Does 8 exist?{list.Includes(8)}");
            Console.WriteLine($"Does 18 exist?{list.Includes(18)}");

            list.Append(10);

            list.InsertBefore(8, 22);

            list.InsertAfter(4, 33);

            list.Print();
        }
示例#18
0
        static void NodeExample()
        {
            LList list = new LList();

            list.Insert(4);
            list.Insert(8);
            list.Insert(15);

            list.Print();

            list.Append(16);
            list.Append(23);
            list.Append(42);

            list.Print();

            list.InsertBefore(23, 53);

            list.InsertAfter(8, 3);
            list.InsertAfter(4, 1);


            list.Print();
        }