#include using namespace std; #include "ArrayVector.h" #include "LinkedList.h" //a slow (= bad) method for displaying a linked list. //the [] operator is O(n), not O(1) void DisplayLL_Slow(LinkedList &LL) { int i; for(i=0;i &LL) { LL.Reset(); //reset the current pointer to the beginning while(!LL.AtEnd()) //if we aren't at the end, { cout << LL.GetCurrent() << ' '; //display the current element LL.GoNext(); //go to the next element } cout << endl; } int main() { int i; LinkedList LL; //create a new linked list of integers for(i=0;i<4;i++) LL.Push(i*i); //add 4 entries to the linked list DisplayLL_Slow(LL); DisplayLL_Fast(LL); //display the linked list using the two methods above LL.Pop(i); //get the most recently pushed element (3*3 = 9) cout << i << endl; //display it LL.Push(10); //insert 10 instead of 9 DisplayLL_Fast(LL); //display the current contents Vector Vec; LL.Dump(Vec); //dump the linked list data into a vector (a good idea when you don't intend //to resize the data any more.) int *LLData; LLData = LL.Dump(); //the same as dumping into a Vector, except it dumps into a memory-leaked pointer. for(i=0;i