Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.0 KiB

  1. //---------------------------------------------------------------------------
  2. // ARRAY_P.h : CPtrArray header file
  3. //
  4. // Copyright (c) 1996 Microsoft Corporation, All Rights Reserved
  5. // Developed by Sheridan Software Systems, Inc.
  6. //---------------------------------------------------------------------------
  7. #ifndef __CPTRARRAY__
  8. #define __CPTRARRAY__
  9. ////////////////////////////////////////////////////////////////////////////
  10. class CPtrArray
  11. {
  12. public:
  13. // Construction
  14. CPtrArray();
  15. // Attributes
  16. int GetSize() const;
  17. int GetUpperBound() const;
  18. void SetSize(int nNewSize, int nGrowBy = -1);
  19. // Operations
  20. // Clean up
  21. void FreeExtra();
  22. void RemoveAll();
  23. // Accessing elements
  24. void* GetAt(int nIndex) const;
  25. void SetAt(int nIndex, void* newElement);
  26. void*& ElementAt(int nIndex);
  27. // Direct Access to the element data (may return NULL)
  28. const void** GetData() const;
  29. void** GetData();
  30. // Potentially growing the array
  31. void SetAtGrow(int nIndex, void* newElement);
  32. int Add(void* newElement);
  33. int Append(const CPtrArray& src);
  34. void Copy(const CPtrArray& src);
  35. // overloaded operator helpers
  36. void* operator[](int nIndex) const;
  37. void*& operator[](int nIndex);
  38. // Operations that move elements around
  39. void InsertAt(int nIndex, void* newElement, int nCount = 1);
  40. void RemoveAt(int nIndex, int nCount = 1);
  41. void InsertAt(int nStartIndex, CPtrArray* pNewArray);
  42. // Implementation
  43. protected:
  44. void** m_pData; // the actual array of data
  45. int m_nSize; // # of elements (upperBound - 1)
  46. int m_nMaxSize; // max allocated
  47. int m_nGrowBy; // grow amount
  48. public:
  49. ~CPtrArray();
  50. //#ifdef _DEBUG
  51. // void Dump(CDumpContext&) const;
  52. // void AssertValid() const;
  53. //#endif
  54. protected:
  55. // local typedefs for class templates
  56. // typedef void* BASE_TYPE;
  57. // typedef void* BASE_ARG_TYPE;
  58. };
  59. ////////////////////////////////////////////////////////////////////////////
  60. ////////////////////////////////////////////////////////////////////////////
  61. #endif //__CPTRARRAY__