CPtrArray Class
Supports arrays of void pointers.
Syntax
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 |
---|---|
CPtrArray::CPtrArray | Constructs an empty array. |
Public Methods
Name | Description |
---|---|
CPtrArray::Add | Adds an element to the end of the array; grows the array if necessary. |
CPtrArray::Append | Appends another array to the array; grows the array if necessary. |
CPtrArray::Copy | Copies another array to the array; grows the array if necessary. |
CPtrArray::ElementAt | Returns a temporary reference to the element pointer within the array. |
CPtrArray::FreeExtra | Frees all unused memory above the current upper bound. |
CPtrArray::GetAt | Returns the value at a given index. |
CPtrArray::GetCount | Gets the number of elements in this array. |
CPtrArray::GetData | Allows access to elements in the array. Can be NULL . |
CPtrArray::GetSize | Gets the number of elements in this array. |
CPtrArray::GetUpperBound | Returns the largest valid index. |
CPtrArray::InsertAt | Inserts an element (or all the elements in another array) at a specified index. |
CPtrArray::IsEmpty | Determines if the array is empty. |
CPtrArray::RemoveAll | Removes all the elements from this array. |
CPtrArray::RemoveAt | Removes an element at a specific index. |
CPtrArray::SetAt | Sets the value for a given index; array not allowed to grow. |
CPtrArray::SetAtGrow | Sets the value for a given index; grows the array if necessary. |
CPtrArray::SetSize | Sets the number of elements to be contained in this array. |
Public Operators
Name | Description |
---|---|
CPtrArray::operator [ ] | 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
See also
Palaute
https://aka.ms/ContentUserFeedback.
Tulossa pian: Vuoden 2024 aikana poistamme asteittain GitHub Issuesin käytöstä sisällön palautemekanismina ja korvaamme sen uudella palautejärjestelmällä. Lisätietoja on täällä:Lähetä ja näytä palaute kohteelle