home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / sysba021.zip / SRC.ZIP / sysbar2 / Piper / cpuload / collect.h < prev    next >
C/C++ Source or Header  |  1997-09-18  |  1KB  |  71 lines

  1. /*
  2. ** Module   :COLLECT.H
  3. ** Abstract :
  4. **
  5. ** Copyright (C) Sergey I. Yevtushenko
  6. ** Log: Fri  05/09/97   Last cleanup before sending it.
  7. */
  8.  
  9. #ifndef  __COLLECT_H
  10. #define  __COLLECT_H
  11.  
  12. #ifndef  __BASE_H
  13. #include "base.h"
  14. #endif
  15.  
  16. CLASSDEF(Collection);
  17.  
  18. typedef void (*ForEachFunc)(Ptr);
  19.  
  20. class Collection
  21. {
  22.     protected:
  23.  
  24.         Ptr * ppData;
  25.         DWord     dwLast;
  26.         DWord     dwCount;
  27.         DWord     dwDelta;
  28.         Byte      bDuplicates;
  29.  
  30.     public:
  31.  
  32.         //───── New
  33.  
  34.         Collection(DWord aCount =10, DWord aDelta =5);
  35.         ~Collection();
  36.         Ptr Get(DWord);
  37.         Ptr Remove(DWord);
  38.  
  39.         virtual void Add(Ptr);
  40.         virtual void At(Ptr, DWord);
  41.         virtual void Free(Ptr p)     { delete p;}
  42.  
  43.         void  ForEach(ForEachFunc);
  44.         DWord Count()                {return dwLast;}
  45.         void  RemoveAll();
  46.  
  47. };
  48.  
  49. CLASSDEF(SortedCollection);
  50.  
  51. class SortedCollection:public Collection
  52. {
  53.     public:
  54.  
  55.         //───── New
  56.  
  57.         SortedCollection(DWord aCount = 10, DWord aDelta = 5):
  58.             Collection(aCount,aDelta){ bDuplicates = 1;};
  59.  
  60.         virtual int   Compare(Ptr p1,Ptr p2)
  61.                         {return *((int *)p1) - *((int *)p2);}
  62.  
  63.         virtual DWord Look(Ptr);
  64.  
  65.         //───── Replaced
  66.  
  67.         virtual void Add(Ptr);
  68. };
  69.  
  70. #endif //__COLLECT_H
  71.