CPtrArray Class
Supports arrays of void pointers.
class CPtrArray : public CObject
Members
The member functions of CPtrArray are similar to the member functions of class CObArray. Because of this similarity, you can use the CObArray reference documentation for member function specifics. Wherever you see a CObject pointer as a function parameter or return value, substitute a pointer to void.
CObject* CObArray::GetAt( int <nIndex> ) const;
for example, translates to
void* CPtrArray::GetAt( int <nIndex> ) const;
Public Constructors
Name |
Description |
---|---|
Constructs an empty array. |
Public Methods
Name |
Description |
---|---|
Adds an element to the end of the array; grows the array if necessary. |
|
Appends another array to the array; grows the array if necessary. |
|
Copies another array to the array; grows the array if necessary. |
|
Returns a temporary reference to the element pointer within the array. |
|
Frees all unused memory above the current upper bound. |
|
Returns the value at a given index. |
|
Gets the number of elements in this array. |
|
Allows access to elements in the array. Can be NULL. |
|
Gets the number of elements in this array. |
|
Returns the largest valid index. |
|
Inserts an element (or all the elements in another array) at a specified index. |
|
Determines if the array is empty. |
|
Removes all the elements from this array. |
|
Removes an element at a specific index. |
|
Sets the value for a given index; array not allowed to grow. |
|
Sets the value for a given index; grows the array if necessary. |
|
Sets the number of elements to be contained in this array. |
Public Operators
Name |
Description |
---|---|
Sets or gets the element at the specified index. |
Remarks
CPtrArray incorporates the IMPLEMENT_DYNAMIC macro to support run-time type access and dumping to a CDumpContext object. If you need a dump of individual pointer array elements, you must set the depth of the dump context to 1 or greater.
Note
Before using an array, use SetSize to establish its size and allocate memory for it. If you do not use SetSize, adding elements to your array causes it to be frequently reallocated and copied. Frequent reallocation and copying are inefficient and can fragment memory.
Pointer arrays cannot be serialized.
When a pointer array is deleted, or when its elements are removed, only the pointers are removed, not the entities they reference.
For more information on using CPtrArray, see the article Collections.
Inheritance Hierarchy
CPtrArray
Requirements
Header: afxcoll.h