home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 038 / dho_9a.zip / LIST.H < prev    next >
C/C++ Source or Header  |  1994-10-12  |  2KB  |  79 lines

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