Beispiel #1
0
        ///<summary>
        ///Print all nodes from start to end.
        ///</summary>
        public void PrintAllNodes(ShaKyList data)
        {
            Console.WriteLine("Head");
            Node curr = data.head;

            while (curr.Next != null)
            {
                curr = curr.Next;
                Console.WriteLine(curr.Value);
            }
            Console.WriteLine("Null");
        }
Beispiel #2
0
        /// <summary>
        /// Prints all nodes in reverse order
        /// </summary>
        public void PrintReverse()
        {
            int  count = 0;
            Node curr  = head;

            ShaKyList reverseList = new ShaKyList();

            while (count < Count)
            {
                if (curr != null && curr.Next != null)
                {
                    curr = curr.Next;
                    reverseList.Add(curr.Value);
                }
                count++;
            }
            reverseList.PrintAllNodes(reverseList);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            object temp = 10;


            Person p = new Person("Bob", 85);

            ShaKyList lnklist = new ShaKyList();

            //used to test indexer performance
            //was happy with result, saw no perfromance dip in this test
            for (int i = 0; i < 10; i++)
            {
                lnklist.Insert(i, i);
                //Console.WriteLine(lnklist.Contains(i));
            }


            //Console.WriteLine();
            //lnklist.PrintReverse();
            //Console.ReadLine();


            //Console.WriteLine();

            //lnklist.AddAtLast("Fun");
            //lnklist.AddAtLast("1");
            //lnklist.AddAtLast("1");
            //lnklist.AddAtLast("1");
            //lnklist.AddAtLast("1");
            //lnklist.AddAtLast("Soon");
            //lnklist.AddAtLast("1");

            //lnklist.PrintAllNodes(lnklist);
            //Console.WriteLine();

            //lnklist.RemoveAt(8);
            //lnklist.PrintAllNodes(lnklist);

            //Console.WriteLine(lnklist[1]);

            //Console.WriteLine();

            //lnklist.Insert("Now", 1);
            //lnklist[1] = "Hey";
            //Console.WriteLine(lnklist[1]);


            //lnklist.RemoveAll("1");
            //Console.WriteLine();

            //lnklist.PrintAllNodes(lnklist);



            foreach (var item in lnklist)
            {
                Console.WriteLine(" foreach " + item);
            }
            Console.ReadKey();
        }