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.

89 lines
2.3 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright � Microsoft Corporation. All rights reserved.
  4. //
  5. // chptrarr.h
  6. //
  7. // Purpose: Non-MFC CPtrArray class definition
  8. //
  9. //***************************************************************************
  10. #if _MSC_VER > 1000
  11. #pragma once
  12. #endif
  13. #ifndef __CHPTRARRAY__
  14. #define __CHPTRARRAY__
  15. #include <windows.h>
  16. #include <limits.h>
  17. #include <assert.h>
  18. #include <tchar.h>
  19. #include <polarity.h>
  20. #include <ProvExce.h>
  21. class POLARITY CHPtrArray
  22. {
  23. public :
  24. // Construction/destruction
  25. //=========================
  26. CHPtrArray() ;
  27. // Attributes
  28. int GetSize() const ;
  29. int GetUpperBound() const ;
  30. void SetSize(int nNewSize, int nGrowBy = -1) throw ( CHeap_Exception ) ;
  31. // Operations
  32. // Clean up
  33. void FreeExtra() throw ( CHeap_Exception ) ;
  34. void RemoveAll() ;
  35. // Accessing elements
  36. void* GetAt(int nIndex) const ;
  37. void SetAt(int nIndex, void* newElement) ;
  38. void*& ElementAt(int nIndex) ;
  39. // Direct Access to the element data (may return NULL)
  40. const void** GetData() const ;
  41. void** GetData() ;
  42. // Potentially growing the array
  43. void SetAtGrow(int nIndex, void* newElement) throw ( CHeap_Exception ) ;
  44. int Add(void* newElement) throw ( CHeap_Exception ) ;
  45. int Append(const CHPtrArray& src) throw ( CHeap_Exception ) ;
  46. void Copy(const CHPtrArray& src) throw ( CHeap_Exception ) ;
  47. // overloaded operator helpers
  48. void* operator[](int nIndex) const ;
  49. void*& operator[](int nIndex) ;
  50. // Operations that move elements around
  51. void InsertAt(int nIndex, void* newElement, int nCount = 1) throw ( CHeap_Exception ) ;
  52. void RemoveAt(int nIndex, int nCount = 1) ;
  53. void InsertAt(int nStartIndex, CHPtrArray* pNewArray) throw ( CHeap_Exception ) ;
  54. // Implementation
  55. protected:
  56. void** m_pData ; // the actual array of data
  57. int m_nSize ; // # of elements (upperBound - 1)
  58. int m_nMaxSize ; // max allocated
  59. int m_nGrowBy ; // grow amount
  60. public:
  61. ~CHPtrArray() ;
  62. #ifdef _DEBUG
  63. // void Dump(CDumpContext&) const ;
  64. void AssertValid() const ;
  65. #endif
  66. protected:
  67. // local typedefs for class templates
  68. typedef void* BASE_TYPE ;
  69. typedef void* BASE_ARG_TYPE ;
  70. } ;
  71. #endif