home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / ResAnomaly 1.2 / ResAnomaly Source / LtDynamicArray.h < prev    next >
Encoding:
Text File  |  1995-06-09  |  2.1 KB  |  73 lines  |  [TEXT/MPCC]

  1.  
  2. /*
  3.  
  4. MWfolk:
  5. I munged this up when CW5 was new, but it never compiled to usable
  6. code, and thus couldn’t use it.  With CW6, it seems to work, so
  7. I'm able to use it again, much to my relief.  If I'd gotten it
  8. to work with CW/5, it would've saved me numerous hours of grief.
  9.  
  10. You have my full permission to do what you like with this;
  11. I suggest it would save future PP users much grief if you
  12. were to replace the standard LDynamicArray with it (or
  13. something like it.)  void * is an abomination always abhorred!
  14. I decided against sending it to macgifts as it remains mostly
  15. your copyrighted material.
  16.  
  17. Further, you could do a StHandleBlock<T> class alongside the
  18. existing such class for UMemoryMgr which would remove some casting
  19. in this version.
  20.  
  21. As always,
  22. Chris
  23. */
  24.  
  25.  
  26. // ===========================================================================
  27. //    LtDynamicArray.t            ©1994-1995 Metrowerks Inc. All rights reserved.
  28. //    templated by Chris Thomas    thunderone@delphi.com
  29. // ===========================================================================
  30.  
  31. #pragma once
  32.  
  33. #include <PP_Prefix.h>
  34.  
  35.  
  36. template <class T>
  37. class LtDynamicArray
  38. {
  39.  
  40. public:
  41.                     LtDynamicArray();
  42.                     LtDynamicArray(T** inItemsHandle);
  43.     virtual            ~LtDynamicArray();
  44.     
  45.     virtual Int32    GetCount() const;
  46.  
  47.     virtual void    InsertItemsAt(Uint32 inCount, Int32 inAtIndex,
  48.                             T *inItem);
  49.     virtual void    RemoveItemsAt(Uint32 inCount, Int32 inAtIndex);
  50.     
  51.     virtual Boolean    FetchItemAt(Int32 inAtIndex, T *outItem);
  52.     virtual void    SetItemAt(Int32 inAtIndex, const T *inItem);
  53.     
  54.     virtual void    SwapItems(Int32 inIndexA, Int32 inIndexB);
  55.     virtual void    MoveItem(Int32 inFromIndex, Int32 inToIndex);
  56.     
  57.     // this doesn't work if /*const*/ is uncommented below - MWC++ template bug ??
  58.     virtual Int32    FetchIndexOf(const T *inItem) const;
  59.     virtual void    Remove(const T* inItem);
  60.                             
  61. protected:
  62.     Int32            mItemSize;
  63.     Int32            mItemCount;
  64.     T                **mItemsH;
  65.     
  66.     virtual T*        GetItemPtr(Int32 inAtIndex) const;
  67.     virtual void    PeekItem(Int32 inAtIndex, T *outItem) const;
  68.     virtual void    PokeItem(Int32 inAtIndex, const T *inItem);
  69.  
  70.     virtual void    ShiftItems(Int32 inStartPos, Int32 inEndPos,
  71.                             Int32 inDestPos);
  72. };
  73.