00001 00002 #define CHECKTRUE(expr) {if((expr) == true) return false;} 00003 00004 // Constructor 00005 // initialize the class 00006 template<typename T> 00007 ArrayList<T>::ArrayList() : Array<T>() { 00008 } 00009 00010 // Constructor 00011 // initialize the class 00012 template<typename T> 00013 ArrayList<T>::ArrayList(uint size) : Array<T>(size) { 00014 } 00015 00016 // Destructor 00017 template<typename T> 00018 ArrayList<T>::~ArrayList(){ 00019 this->uninit(); 00020 } 00021 00022 // add a new element 00023 // at the end of the list 00024 template<typename T> 00025 bool ArrayList<T>::add(T data){ 00026 // check if the list is 00027 // big enough 00028 if(this->last >= this->len) 00029 if(this->resize(this->last*2) == false) 00030 return false; 00031 this->array[this->last++] = data; 00032 return true; 00033 } 00034 00035 #undef CHECKTRUE