Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

skAlist.h

00001 /*
00002   Copyright 1996-2003
00003   Simon Whiteside
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 * $Id: skAlist_8h-source.html,v 1.7 2003/02/24 20:05:01 simkin_cvs Exp $
00020 */
00021 
00022 #ifndef skALIST_H
00023 #define skALIST_H
00024 
00025 
00026 #include "skGeneral.h"
00027   
00028 class  CLASSEXPORT skAList;  
00029 
00030 const USize     DEFAULT_SIZE=0;                         // so nothing is allocated until needed
00031 const USize     DEFAULT_GROWTH_INCREMENT=4;     // value of 0 means 'double in size'
00032 
00033 
00037 class  CLASSEXPORT skAListIterator 
00038 {       
00039  public:
00043   void  reset();
00047   virtual ~skAListIterator();
00048  protected:
00052   skAListIterator(const skAList&);
00056   skAListIterator& operator=(const skAListIterator&);
00060   void * operator()();
00061  private:
00065   USize m_Current;
00069   const skAList& m_AList;
00070 };    
00075 class  CLASSEXPORT skAList 
00076 {   
00077  public:
00081   skAList();
00087   skAList(USize initial_size,USize growth_increment);
00091   virtual ~skAList();       
00095   void clearAndDestroy();
00099   void clear();
00103   USize entries() const;
00107   void deleteElt(USize  n);
00111   void test() const;
00115   void growTo(USize size);
00116  protected:
00120   void insert(void *,USize index);
00124   void prepend(void *);
00128   void append(void *);
00132   void remove(void *);
00136   void removeAndDestroy(void *); 
00140   void * operator[](USize  n) const;
00144   int index(const void *) const;
00148   bool contains(const void *) const;
00152   virtual void deleteItem(void *)=0;
00153   friend class skAListIterator;
00157   int findElt(const void * i) const;
00161   void grow();
00165   void ** m_Array;
00169   USize m_ArraySize;
00173   USize m_Entries;
00177   USize m_GrowthIncrement;      
00178 
00179  private:
00183   skAList(const skAList&);
00187   skAList& operator=(const skAList&);
00188 };    
00192 template <class T> class CLASSEXPORT skTAList : public skAList
00193 {
00194  public:
00198   skTAList();
00202   skTAList(USize initial_size,USize growth_increment);
00206   virtual ~skTAList();
00210   void insert(T *,USize index);
00214   void prepend(T *);
00218   void append(T *);
00222   void remove(T *);
00226   void removeAndDestroy(T *);
00230   T * operator[](USize  n) const;
00234   int index(const T *) const;
00238   bool contains(const T *) const;
00239  protected:
00243   void deleteItem(void *);
00244  private:
00248   skTAList<T>& operator=(const skTAList<T>& l);
00252   skTAList(const skTAList<T>&);
00253 };
00257 template <class T> class CLASSEXPORT skTAListIterator : public skAListIterator
00258 {       
00259  public:
00263   skTAListIterator(const skTAList<T>&);
00267   T * operator()();
00268 };    
00269 
00270 #include "skAlist.inl"
00271 
00272 #endif
00273 
00274 
00275 
00276 

Generated on Mon Feb 24 20:00:02 2003 for Simkin by doxygen1.3-rc1