home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dho.zip / DHO / SRC / LIST.H < prev    next >
C/C++ Source or Header  |  1995-08-27  |  2KB  |  79 lines

  1. /****************************************/
  2. /*    Developer Helper Object Set       */
  3. /*  (C) 1994-95 Thomas E. Bednarz, Jr.  */
  4. /*     All rights reserved              */
  5. /***************************************/
  6.  
  7. /* $Id: list.h 1.4 1995/08/13 03:21:12 teb Exp $ */
  8.  
  9. #ifndef __LIST_H__
  10. #define __LIST_H__
  11.  
  12.  
  13. #include <object.h>
  14.  
  15. typedef short unsigned ushort;
  16. typedef unsigned char uchar;
  17.  
  18.  
  19. typedef Boolean (TestFunc)( TObject*, void * );
  20. typedef void (*AppFunc)( TObject*, void* );
  21.  
  22.  
  23. const char EOS = '\0';
  24.  
  25. typedef short ListIndex;
  26.  
  27. const ccNotFound = -1;
  28. const maxCollectionSize = (int)((65536uL - 16)/sizeof( TObject* ));
  29.  
  30.  
  31. class TList: public TObject
  32. {
  33.  
  34.       virtual void freeItem( TObject *item );
  35.    protected:
  36.  
  37.        TObject **fItems;
  38.        ListIndex fCount;
  39.        ListIndex fLimit;
  40.        ListIndex fDelta;
  41.        Boolean fShouldDelete;   
  42.  
  43.          TList();
  44.    public:
  45.        TList(ListIndex aLimit, ListIndex aDelta);
  46.        virtual ~TList();
  47.  
  48.        TObject *at(ListIndex index);
  49.        virtual ListIndex indexOf(TObject *item);
  50.  
  51.        void atFree(ListIndex index);   
  52.        void atRemove(ListIndex index);
  53.        void remove(TObject *item);
  54.        void removeAll();
  55.        void free(TObject *item);
  56.        void freeAll();
  57.  
  58.        void atInsert(ListIndex index, TObject *item);
  59.        void atPut(ListIndex index, TObject *item);
  60.        virtual ListIndex insert(TObject *item);
  61.  
  62.        static void error(ListIndex code, ListIndex info);
  63.  
  64.        TObject *firstThat(TestFunc Test, void *arg);
  65.        TObject *lastThat(TestFunc Test, void *arg);
  66.        void forEach(AppFunc action, void *arg); 
  67.  
  68.        void pack();
  69.        virtual void setLimit(ListIndex aLimit);
  70.  
  71.        ListIndex getCount();
  72.  
  73.        virtual const char *getClassName(void);
  74.  
  75. };
  76.  
  77. #endif
  78.  
  79.