CObArray::SetAtGrow

voidSetAtGrow(intnIndex**,CObject*newElement);**
throw(CMemoryException);

Parameters

nIndex

An integer index that is greater than or equal to 0.

newElement

The object pointer to be added to this array. A NULL value is allowed.

Remarks

Sets the array element at the specified index. The array grows automatically if necessary (that is, the upper bound is adjusted to accommodate the new element).

The following table shows other member functions that are similar to CObArray::SetAtGrow.

Class Member Function
CByteArray void SetAtGrow( int nIndex, BYTE newElement );
    throw(CMemoryException);
CDWordArray void SetAtGrow( int nIndex, DWORD newElement );
    throw(CMemoryException);
CPtrArray void SetAtGrow( int nIndex, void* newElement );
    throw(CMemoryException);
CStringArray void SetAtGrow( int nIndex, LPCTSTR newElement );
    throw(CMemoryException);
CUIntArray void SetAtGrow( int nIndex, UINT newElement );
    throw(CMemoryException);
CWordArray void SetAtGrow( int nIndex, WORD newElement );
    throw(CMemoryException);

Example

See CObList::CObList for a listing of the CAge class used in all collection examples.

// example for CObArray::SetAtGrow

   CObArray array;

   array.Add( new CAge( 21 ) ); // Element 0
   array.Add( new CAge( 40 ) ); // Element 1
   array.SetAtGrow( 3, new CAge( 65 ) ); // Element 2 deliberately
                                         // skipped.
#ifdef _DEBUG
   afxDump.SetDepth( 1 );
   afxDump << "SetAtGrow example: " << &array << "\n";
#endif

The results from this program are as follows:

SetAtGrow example: A CObArray with 4 elements
    [0] = a CAge at $47C0 21
    [1] = a CAge at $4800 40
    [2] = NULL
    [3] = a CAge at $4840 65

CObArray OverviewClass MembersHierarchy Chart

See Also   CObArray::GetAt, CObArray::SetAt, CObArray::ElementAt, CObArray::operator []