void InsertAt ( int nIndex, CObject * newElement, int nConteggio = 1 );
gettare ( CMemoryException );
void InsertAt ( int nStartIndex, CObArray * pNewArray );
gettare ( CMemoryException );
Parametri
nIndex
Un indice di integer che può essere maggiore del valore restituito da GetUpperBound.
newElement
Il puntatore CObject verranno inseriti in questa matrice. È consentito un newElement di valore NULL.
nConteggio
Il numero di volte che questo elemento dovrebbe essere inserito (default 1).
nStartIndex
Un indice di integer che può essere maggiore del valore restituito da GetUpperBound.
pNewArray
Un altro array che contiene gli elementi da aggiungere a questa matrice.
Osservazioni
La prima versione di InsertAt inserisce un elemento (o più copie di un elemento) un indice specificato in una matrice. Nel processo, si sposta (aumentando l'indice) dell'elemento esistente a questo indice e si sposta su tutti gli elementi sopra di esso.
La seconda versione inserisce tutti gli elementi da un'altra collezione di CObArray , a partire dalla posizione di nStartIndex.
La funzione SetAt , al contrario, sostituisce un elemento di matrice specificata e non spostare tutti gli elementi.
La tabella seguente mostra altre funzioni membro che sono simili a CObArray::InsertAt.
| Classe | Funzione membro |
| CByteArray | public static void I&nsertAt (int nIndex, BYTE newElement, int nConteggio=1); nbsp;gettare ( CMemoryException );
public static void InsertAt (int nStartIndex, CByteArray * p&NewArray ); |
| CDWordArray | public static void I&nsertAt (int nIndex, DWORD newElement, int nConteggio=1); nbsp;gettare ( CMemoryException );
public static void InsertAt (int nStartIndex, CDWordArray * p&NewArray ); |
| CPtrArray | public static void I&nsertAt (int nIndex, void * newElement, int nConteggio=1); nbsp;gettare ( CMemoryException );
public static void InsertAt (int nStartIndex, CPtrArray * p&NewArray ); |
| CStringArray | public static void I&nsertAt (int nIndex, LPCTSTR newElement, int nConteggio=1); nbsp;gettare ( CMemoryException );
public static void InsertAt (int nStartIndex, CStringArray * p&NewArray ); |
| CUIntArray | public static void InsertAt (int nIndex, UI&NT newElement, int nConteggio=1); nbsp;gettare ( CMemoryException );
public static void InsertAt (int nStartIndex, CUIntArray * p&NewArray ); |
| CWordArray | public static void I&nsertAt (int nIndex, WORD newElement, int nConteggio=1); nbsp;gettare ( CMemoryException );
public static void InsertAt (int nStartIndex, CWordArray * p&NewArray ); |
Esempio
Vedere CObList::CObList per un elenco della CAge classe utilizzata in tutti gli esempi di raccolta.
/ / esempio per CObArray::InsertAt
nbsp; Matrice di CObArray;
matrice.Aggiungi (nuova gabbia (21)); / / Elemento 0
matrice.Aggiungi (nuova gabbia (40)); / / Elemento 1 (diventerà 2).
matrice.InsertAt (1, nuova gabbia (30)); / / Nuovo elemento 1
ifdef debug
afxDump.SetDepth (1);
afxDump << "InsertAt esempio:" << & matrice << "\n";
# endif
I risultati di questo programma sono i seguenti:
Esempio I&nsertAt: un CObArray con 3 elementi
nbsp; [0] = una gabbia a $45 C 8 21
[1] = una gabbia di 4646 $ 30
[2] = una gabbia di 4606 $ 40
Pa&noramica CObArray |nbsp; Membri della classe | Gerarchia Chart
Vedere a&nchenbsp;CObArray::SetAt, CObArray::RemoveAt