Share via


CAtlArray::SetAtGrow

Call this method to set the value of an element in the array object, expanding the array as required.

void SetAtGrow( 
   size_t iElement, 
   INARGTYPE element  
);

Parameters

  • iElement
    The index pointing to the array element to set.

  • element
    The new value of the specified element.

Remarks

Replaces the value of the element pointed to by the index. If iElement is larger than the current size of the array, the array is automatically increased using a call to CAtlArray::SetCount. In debug builds, an ATLASSERT will be raised if the CAtlArray object is not valid. In retail builds, invalid parameters may cause unpredictable results.

Example

// Declare an array of integers
CAtlArray<int> iGrowArray;

// Add an element
iGrowArray.Add(0);

// Add an extra element at position 19. 
// This will grow the array to accommodate.
iGrowArray.SetAtGrow(19, 0);

// Confirm size of new array
ATLASSERT(iGrowArray.GetCount() == 20);

// Note: the values at position 1 to 18 
// are undefined.

Requirements

Header: atlcoll.h

See Also

Reference

CAtlArray Class

CAtlArray::SetAt