예제 #1
0
        static void Main(string[] args)
        {
            OurList myList = new OurList();

            for (int i = 0; i < 10; i++)
            {
                myList.PushBack(i);
            }
            myList.Display();

            Console.WriteLine("The 5th value on the list is {0}", myList.GetNthValue(5));
            myList.Clear();
            for (int i = 0; i < 10; i++)
            {
                myList.PushBack(i);
            }

            myList.Display();
            Console.WriteLine("The 6th value on the list is {0}", myList.GetNthValue(6));
            myList.Clear();
            for (int i = 0; i < 10; i++)
            {
                myList.PushBack(i);
            }

            myList.Display();
            Console.WriteLine("The 12th value on the list is {0}", myList.GetNthValue(12));

            Console.WriteLine();
            Console.WriteLine("Press any key to continue ...");
            Console.ReadKey();
        }
예제 #2
0
        public OurList(OurList aList)       // a Deep copy
        {
            mFirst = null;
            OurListNode pCopy = aList.mFirst;

            while (pCopy != null)
            {
                PushBack(pCopy.mData);
                pCopy = pCopy.mNext;
            }
        }
예제 #3
0
        // a Deep copy
        public OurList(OurList aList)
        {
            mFirst = null;
                OurListNode pCopy = aList.mFirst;

                while (pCopy != null)
                {
                    PushBack(pCopy.mData);
                    pCopy = pCopy.mNext;
                }
        }
예제 #4
0
        static void Main(string[] args)
        {
            OurList myList = new OurList();
                for (int i = 0; i < 10; i++)
                    myList.PushBack(i);
                    myList.Display();

                Console.WriteLine("The 5th value on the list is {0}", myList.GetNthValue(5));
                myList.Clear();
                for (int i = 0; i < 10; i++)
                   myList.PushBack(i);

               myList.Display();
               Console.WriteLine("The 6th value on the list is {0}", myList.GetNthValue(6));
               myList.Clear();
               for (int i = 0; i < 10; i++)
                   myList.PushBack(i);

                myList.Display();
                Console.WriteLine("The 12th value on the list is {0}", myList.GetNthValue(12));

                Console.WriteLine();
                Console.WriteLine("Press any key to continue ...");
                Console.ReadKey();
        }