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(); }
public OurList(OurList aList) // a Deep copy { mFirst = null; OurListNode pCopy = aList.mFirst; while (pCopy != null) { PushBack(pCopy.mData); pCopy = pCopy.mNext; } }
// a Deep copy public OurList(OurList aList) { mFirst = null; OurListNode pCopy = aList.mFirst; while (pCopy != null) { PushBack(pCopy.mData); pCopy = pCopy.mNext; } }
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(); }