Removes one or more elements starting at a specified index in an vector. It can removes elements at specified indices in a vector also.
BOOL RemoveAt( int nIndex, int nCount = 1 )
BOOL RemoveAt(const vector<int>& vnIndices)
Always returns TRUE
EX1
void vector_RemoveAt_ex1() { vector<string> vsExt = {"OPJ", "TXT", "SPC"}; vsExt.RemoveAt(0, 2); for(int ii = 0; ii < vsExt.GetSize(); ii++) { printf("Extesion(%d) : %s\n", ii, vsExt[ii]); } } //Result: // Extesion(0) : SPC
EX2
void vector_RemoveAt_ex2() { vector vdElements = {123, 10, 23}; vector<int> vnIndices = {0, 2}; vdElements.RemoveAt(vnIndices); for(int ii = 0; ii < vdElements.GetSize(); ii++) { printf("%.f\n", vdElements[ii]); } //Output will be: 10 }
Removes one or more elements starting at a specified index in a vector. In the process, it shifts down all the elements above the removed element(s). It decrements the upper bound of the vector. If nIndex is out of bound, or if (nIndex + nCount-1)is out of bound, then runtime error will be generated.
Removes elements at specified indices in a vector. In the process, it shifts down all the elements above the removed element(s) which are not removed. It decrements the upper bound of the vector. If the size of the indices is zero or any of the indices is out of bound, then runtime error will be generated. The duplicated indices will be skipped.
vector::InsertAt, vector::InsertValue
origin.h