Inserts one element, or multiple copies of an element at a specified index in an vector. In the process, by incrementing the index, it shifts up the existing element at this index, and it shifts up all the elements above it.
BOOL InsertAt( int nIndex, _TemplType element, int nCount = 1 )
Always returns TRUE
EX1
// Insert one string at the specified index in vector void vector_InsertAt_ex1() { vector<string> vsExt = {"OPJ", "TXT"}; vsExt.InsertAt(0, "SPC"); for(int ii = 0; ii < vsExt.GetSize(); ii++) printf("Extesion(%d) : %s\n", ii, vsExt[ii]); //Result value: vsExt = {"SPC","OPJ","TXT"} }
EX2
// Insert double data at the specified index in vector void vector_InsertAt_ex2() { vector<double> vD = {1.1, 2.2}; double d = (3.999); vD.InsertAt(1, d); for(int ii = 0; ii < vD.GetSize(); ii++) printf("vD[%d]= %g\n", ii, vD[ii]); // Result: //vD[0]= 1.1 //vD[1]= 3.999 //vD[2]= 2.2 }
EX3
// Insert complex data at the specified index in vector void vector_InsertAt_ex3() { vector<complex> vC; complex cc1(4.3, 5.6); complex cc2(3, 2); complex cc3(2, 1); vC.Add(cc1); vC.Add(cc2); vC.InsertAt(1, cc3); for(int ii = 0; ii < vC.GetSize(); ii++) out_complex("value=", vC[ii]); // Result: //value=4.300000+5.600000i //value=2.000000+1.000000i //value=3.000000+2.000000i }
vector::SetAtGrow, vector::Add
origin.h