Condividi tramite


CObArray::RemoveAt

Elimina uno o più elementi che iniziano a un indice specificato in una matrice.

void RemoveAt(
   INT_PTR nIndex,
   INT_PTR nCount = 1 
);

Parametri

  • nIndex
    Un intero maggiore o uguale a 0 e minore o uguale al valore restituito da GetUpperBound.

  • nCount
    Numero di elementi da rimuovere.

Note

Nel processo, scorrere verso il basso tutti gli elementi sugli elementi eliminati.Decrementa il limite massimo della matrice ma non fa memoria.

Se si tenta di eliminare più elementi contenuti nella matrice sul punto di rimozione, la versione di debug delle asserzioni di libreria.

La funzione RemoveAt rimuove il puntatore CObject dalla matrice, ma non elimina l'oggetto stesso.

Nella tabella seguente vengono illustrate altre funzioni membro che sono simili a CObArray::RemoveAt.

Classe

Funzione membro

CByteArray

void RemoveAt( INT_PTR nIndex, INT_PTR nCount = 1 );

CDWordArray

void RemoveAt( INT_PTR nIndex, INT_PTR nCount = 1 );

CPtrArray

void RemoveAt( INT_PTR nIndex, INT_PTR nCount = 1 );

CStringArray

void RemoveAt( INT_PTR nIndex, INT_PTR nCount = 1 );

CUIntArray

void RemoveAt( INT_PTR nIndex, INT_PTR nCount = 1 );

CWordArray

nCount = 1 );divoid RemoveAt( INT_PTRnIndex, INT_PTR

Esempio

Vedere CObList::CObList per un elenco CAge utilizzata in tutti gli esempi di raccolta.

CObArray arr;
CObject* pa;

arr.Add(new CAge(21)); // Element 0
arr.Add(new CAge(40)); // Element 1
if((pa = arr.GetAt(0)) != NULL)
{
    arr.RemoveAt(0);  // Element 1 moves to 0.
    delete pa; // Delete the original element at 0.
}
#ifdef _DEBUG
   afxDump.SetDepth(1);
   afxDump << _T("RemoveAt example: ") << &arr << _T("\n");
#endif      

I risultati di questo programma sono:

RemoveAt example: A CObArray with 1 elements

[0] = a CAge at $4606 40

Requisiti

Header: afxcoll.h

Vedere anche

Riferimenti

Classe di CObArray

Grafico della gerarchia

CObArray::SetAt

CObArray::SetAtGrow

CObArray::InsertAt