Skip to content

Latest commit

 

History

History
90 lines (63 loc) · 5.44 KB

cptrarray-class.md

File metadata and controls

90 lines (63 loc) · 5.44 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: CPtrArray Class
CPtrArray Class
11/04/2016
CPtrArray
AFXCOLL/CPtrArray
AFXCOLL/CPtrArray::CPtrArray
AFXCOLL/CPtrArray::Add
AFXCOLL/CPtrArray::Append
AFXCOLL/CPtrArray::Copy
AFXCOLL/CPtrArray::ElementAt
AFXCOLL/CPtrArray::FreeExtra
AFXCOLL/CPtrArray::GetAt
AFXCOLL/CPtrArray::GetCount
AFXCOLL/CPtrArray::GetData
AFXCOLL/CPtrArray::GetSize
AFXCOLL/CPtrArray::GetUpperBound
AFXCOLL/CPtrArray::InsertAt
AFXCOLL/CPtrArray::IsEmpty
AFXCOLL/CPtrArray::RemoveAll
AFXCOLL/CPtrArray::RemoveAt
AFXCOLL/CPtrArray::SetAt
AFXCOLL/CPtrArray::SetAtGrow
AFXCOLL/CPtrArray::SetSize
CPtrArray [MFC], CPtrArray
CPtrArray [MFC], Add
CPtrArray [MFC], Append
CPtrArray [MFC], Copy
CPtrArray [MFC], ElementAt
CPtrArray [MFC], FreeExtra
CPtrArray [MFC], GetAt
CPtrArray [MFC], GetCount
CPtrArray [MFC], GetData
CPtrArray [MFC], GetSize
CPtrArray [MFC], GetUpperBound
CPtrArray [MFC], InsertAt
CPtrArray [MFC], IsEmpty
CPtrArray [MFC], RemoveAll
CPtrArray [MFC], RemoveAt
CPtrArray [MFC], SetAt
CPtrArray [MFC], SetAtGrow
CPtrArray [MFC], SetSize
c23b87a3-bf84-49d6-a66b-61e999d0938a

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

CObject

CPtrArray

Requirements

Header: afxcoll.h

See also

CObject Class
Hierarchy Chart
CObArray Class