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
1.8 KiB

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