Compartir a través de


CAtlArray::SetCount

Call this method to set the size of the array object.

bool SetCount( 
   size_t nNewSize, 
   int nGrowBy = - 1  
);

Parameters

  • nNewSize
    The required size of the array.

  • nGrowBy
    A value used to determine how large to make the buffer. A value of -1 causes an internally calculated value to be used.

Return Value

Returns true if the array is successfully resized, false otherwise.

Remarks

The array can be increased or decreased in size. If increased, extra empty elements are added to the array. If decreased, the elements with the largest indices will be deleted and memory freed.

Use this method to set the size of the array before using it. If SetCount is not used, the process of adding elements — and the subsequent memory allocation performed — will reduce performance and fragment memory.

Example

See the example for CAtlArray::GetData.

Requirements

Header: atlcoll.h

See Also

Reference

CAtlArray Class