home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / text / indxcoll.hpp < prev    next >
Text File  |  1997-04-02  |  1KB  |  42 lines

  1. // @(#) 1.1 com/src/samples/text/indxcoll.hpp, odtextpart, od96os2, odos29712d 12/19/96 11:26:25 [3/21/97 17:49:31]
  2. #ifndef _INDXCOLL_HPP_
  3. #define _INDXCOLL_HPP_
  4.  
  5. typedef void* ElementType;
  6. #define ElementSize sizeof(ElementType)
  7.  
  8. class IndexedCollection  // An indexable collection of ElementTypes
  9. {
  10.  
  11. public:
  12.  
  13.   IndexedCollection();
  14.   virtual ~IndexedCollection();
  15.  
  16.   // Retrieval Methods
  17.   int Count() const;
  18.   ElementType  First();
  19.   ElementType  FromIndex(int index);
  20.   ElementType  Next(int index);
  21.   ElementType  Previous(int index);
  22.   ElementType  Last();
  23.  
  24.   // Addition/Deletion methods
  25.   virtual void  AddLast(int numToAdd, ElementType* elemsToAdd);
  26.   virtual void  AddBefore(int index, int numToAdd, ElementType* elemsToAdd);
  27.   virtual ElementType  RemoveLast();
  28.   virtual ElementType  RemoveFrom(int index);
  29.   virtual ElementType* RemoveFromTo(int lowIndex, int highIndex);
  30.  
  31.   private:
  32.     // data
  33.     ElementType* elements;
  34.     int    numElements;
  35.     int    maxElements;
  36.  
  37.     // methods
  38.     ElementType* AllocElements(int numElem);
  39. };
  40.  
  41. #endif // _INDXCOLL_HPP_
  42.