Udostępnij za pośrednictwem


CAtlArray::RemoveAt

Call this method to remove one or more elements from the array.

void RemoveAt(
   size_t iElement,
   size_t nCount = 1 
);

Parameters

  • iElement
    The index of the first element to remove.

  • nCount
    The number of elements to remove.

Remarks

Removes one or more elements from the array. Any remaining elements are shifted down. The upper bound is decremented, but memory is not freed until a call to CAtlArray::FreeExtra is made.

In debug builds, an ATLASSERT will be raised if the CAtlArray object is not valid, or if the combined total of iElement and nCount exceeds the total number of elements in the array. In retail builds, invalid parameters may cause unpredictable results.

Example

// Declare an array of chars
CAtlArray<char> cMyArray;

// Add ten elements to the array
for (int a = 0; a < 10; a++)
{
   cMyArray.Add('*');
}

// Remove five elements starting with
// the element at position 1
cMyArray.RemoveAt(1, 5);

// Free memory
cMyArray.FreeExtra();

// Confirm size of array
ATLASSERT(cMyArray.GetCount() == 5);   

Requirements

Header: atlcoll.h

See Also

Reference

CAtlArray Class

CAtlArray::RemoveAll

Other Resources

CAtlArray Members