prg_vector_insert()
Abstract
Introduces an element into a vector and, if necessary, shifts all higher-indexed elements to create space.
Syntax
prg_vector_insert (vector_ptr, element_ptr, pos_index)
| Argument | Type | Description |
|---|---|---|
vector_ptr |
PrgT_Vector * |
vector of interest |
element_ptr |
void * |
element to be introduced into the vector |
pos_index |
unsigned long |
position of the element in the vector (zero-indexed). Can be numeric or one of the symbolic constants described in Details. |
Return Type
PrgT_Compcode
Indicates success/failure. Failure only occurs due to insufficient memory resources.
Header
prg_vector.h
Details
As opposed to prg_vector_set(), which replaces elements, this function creates space by shifting elements toward higher positions in the vector. The element is then introduced into the specified position. If necessary, the shifting may cause the vector's memory resources to expand.
Position indices are zero-indexed. In other words, the first element has position index 0, the second is 1, and so on.
In addition to an explicit numeric value, pos_index can be specified as one of the following symbolic constants:
PRGC_VECTOR_INSERT_POS_HEAD—inserts the element at the first (0th) position of the vectorPRGC_VECTOR_INSERT_POS_TAIL—inserts the element at the end (highest) position of the vector