00001 const int LIST_SIZE = 10; 00002 typedef int Elem; 00003 00004 class List { // List class ADT 00005 public: 00006 List(int =LIST_SIZE); // Constructor 00007 ~List(); // Destructor 00008 void clear(); // Remove all Elems from list 00009 void insert(const Elem); // Insert Elem at current pos 00010 void append(const Elem); // Insert Elem at tail of list 00011 Elem remove(); // Remove + return current Elem 00012 void setFirst(); // Set curr to first position 00013 void prev(); // Move curr to previous pos 00014 void next(); // Move curr to next position 00015 int length() const; // Return current length of list 00016 void setPos(int); // Set curr to specified pos 00017 void setValue(const Elem); // Set current Elem's value 00018 Elem currValue() const; // Return current Elem's value 00019 bool isEmpty() const; // Return TRUE if list is empty 00020 bool isInList() const; // TRUE if curr is within list 00021 bool find(int); // Find value (from current pos) 00022 }; 00023 00024 void print(List); // Prototype for print function. 00025 00026 main() 00027 { 00028 List L1; 00029 List L2(15); 00030 List L3; 00031 00032 L2.append(12); // L2 now ( 12 ) 00033 print(L2); 00034 L2.append(20); // L2 now ( 12, 20 ) 00035 L2.append(15); // L2 now ( 12, 20, 15 ) 00036 print(L2); 00037 L1.setFirst(); 00038 L1.insert(39); // L1 now ( 39 ) 00039 L1.next(); // L1 now ( 39, 12 ) 00040 L1.insert(12); 00041 return(0); 00042 }