00001 /* 00002 Copyright 1996-2001 00003 Simon Whiteside 00004 00005 * $Id: skAlist_h-source.html,v 1.19 2001/11/05 19:22:33 sdw Exp $ 00006 */ 00007 00008 #ifndef skALIST_H 00009 #define skALIST_H 00010 00011 00012 #include "skGeneral.h" 00013 00014 class CLASSEXPORT skAList; 00015 00019 class CLASSEXPORT skAListIterator 00020 { 00021 public: 00025 void reset(); 00029 virtual ~skAListIterator(); 00030 protected: 00034 skAListIterator(const skAList&); 00038 skAListIterator& operator=(const skAListIterator&); 00042 void * operator()(); 00043 private: 00047 USize m_Current; 00051 const skAList& m_AList; 00052 }; 00057 class CLASSEXPORT skAList 00058 { 00059 public: 00063 skAList(); 00069 skAList(USize initial_size,USize growth_increment); 00073 virtual ~skAList(); 00077 void clearAndDestroy(); 00081 void clear(); 00085 USize entries() const; 00089 void deleteElt(USize n); 00093 void test() const; 00097 void growTo(USize size); 00098 protected: 00102 void insert(void *,USize index); 00106 void prepend(void *); 00110 void append(void *); 00114 void remove(void *); 00118 void removeAndDestroy(void *); 00122 void * operator[](USize n) const; 00126 int index(const void *) const; 00130 bool contains(const void *) const; 00134 virtual void deleteItem(void *)=0; 00135 friend class skAListIterator; 00139 int findElt(const void * i) const; 00143 void grow(); 00147 void ** m_Array; 00151 USize m_ArraySize; 00155 USize m_Entries; 00159 USize m_GrowthIncrement; 00160 00161 private: 00165 static const USize DEFAULT_SIZE; 00169 static const USize DEFAULT_GROWTH_INCREMENT; 00173 skAList(const skAList&); 00177 skAList& operator=(const skAList&); 00178 }; 00182 template <class T> class CLASSEXPORT skTAList : public skAList 00183 { 00184 public: 00188 skTAList(); 00192 skTAList(USize initial_size,USize growth_increment); 00196 virtual ~skTAList(); 00200 void insert(T *,USize index); 00204 void prepend(T *); 00208 void append(T *); 00212 void remove(T *); 00216 void removeAndDestroy(T *); 00220 T * operator[](USize n) const; 00224 int index(const T *) const; 00228 bool contains(const T *) const; 00229 protected: 00233 void deleteItem(void *); 00234 private: 00238 skTAList<T>& operator=(const skTAList<T>& l); 00242 skTAList(const skTAList<T>&); 00243 }; 00247 template <class T> class CLASSEXPORT skTAListIterator : public skAListIterator 00248 { 00249 public: 00253 skTAListIterator(const skTAList<T>&); 00257 T * operator()(); 00258 }; 00259 00260 #include "skAlist.inl" 00261 00262 #endif 00263 00264 00265 00266