CAtlArray::InsertAt

Call this method to insert a new element (or multiple copies of an element) into the array object.

void InsertAt(
   size_t iElement,
   INARGTYPE element,
   size_t nCount = 1 
);

Parameters

  • iElement
    The index where the element or elements are to be inserted.

  • element
    The value of the element or elements to be inserted.

  • nCount
    The number of elements to add.

Remarks

Inserts one or more elements into the array, starting at index iElement. Existing elements are moved to avoid being overwritten.

In debug builds, an ATLASSERT will be raised if the CAtlArray object is invalid, the number of elements to be added is zero, or the combined number of elements is too large for the array to contain. In retail builds, passing invalid parameters may cause unpredictable results.

Example

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

// Add elements to the array
for (int b = 0; b < 10; b++)
{
   iBuffer.Add(0);
}

// Instert ten 1's into the array
// at position 5
iBuffer.InsertAt(5, 1, 10);   

Requirements

Header: atlcoll.h

See Also

Reference

CAtlArray Class

CAtlArray::Add

Other Resources

CAtlArray Members