StrArray add/remove/insert elements

Web Site  Methods

 
StrArray::Add
 
int Add (const STRCHAR* elem)
int Add (const Str& elem)
int Add (const CString& elem)
The third overload is available only for modules using MFC

Add will append the passed element at the end of the array.  The array size will be increased by one.  The returned value is the 0-based index of the newly added element (i.e. the new value of the array upper limit)

Invoking Add achieves the same effect as SetAtGrow (GetUpperLimit(), elem)

 

 
StrArray::Append
 
int Append (const StrArray& src)
int Append (const CStringArray& src)
The second overload is available only for modules using MFC

Append will append all elements from the passed source string array to the called StrArray object. The returned value is the 0-based index of the first appended element.

 

 
StrArray::InsertAt
 
void InsertAt (int index, const STRCHAR* elem, int nCount = 1)
void InsertAt (int index, const Str& elem, int nCount = 1)
void InsertAt (int index, const CString& elem, int nCount = 1)
The third overload is available only for modules using MFC

InsertAt will insert the specified string at the given array index, shifting all existing elements and increasing the array size.  If a value other than 1 is specified as the insert count, that number of elements will be inserted (and they all will contain a copy of the specified source string).

The passed 0-based index must be less than or equal to the upper limit of the array.

 

 
StrArray::InsertAt
 
void InsertAt (int index, const StrArray& newArray)

This overload of InsertAt will insert a copy of all the elements of the passed newArray at the 0-based index. The index must be less than or equal to the upper limit of the array.

After the operation, the size of the destination array will increase by newArray.GetSize()

 

 
StrArray::RemoveAt
 
void RemoveAt (int index, int nCount = 1)

RemoveAt will delete the specified number of elements (1 by default) at the given 0-based index in the array.  The number of elements to be deleted cannot be greater than the number of elements available at the source index.

All remaining elements will be shifted "downwards" and the array size will be decreased by nCount.

 

See alsoStrArray class