VecInsertRangeL
Description
Insert a contiguous range of elements at the given index, preserving order. L-value form: takes ownership of the source range on success when the vector has no copy_init handler (source bytes are zeroed). On failure the source is left untouched.
Parameters
| Name | Direction | Description |
|---|---|---|
v |
in,out | Vector handle. |
varr |
in | Pointer to the source array. Must be non-NULL when count > 0. |
idx |
in | Position in [0, length]. |
count |
in | Number of elements to insert. |
Usage example (from documentation)
int items[] = { 1, 2, 3 };
if (!VecInsertRangeL(&v, items, 0, 3)) { /* recover */ }Success
Returns true. The vector length grows by count. Source bytes now occupy indices [idx, idx + count); previous elements at and after idx have shifted right by count. When the vector has no copy_init handler, the count * sizeof(element) source bytes have been zeroed.
Failure
Returns false on allocation failure. Both vector and source are unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Vec.Insert.c:477:
// Test VecInsertRangeL
int range[] = {80, 90, 100};
VecInsertRangeL(&vec, range, 1, 3);
// Check that array elements are zeroed
- In
Insert.h:206:
/// TAGS: Vec, Insert, Range
///
#define VecInsertRange(v, varr, idx, count) VecInsertRangeL((v), (varr), (idx), (count))
///
- In
Insert.h:272:
/// TAGS: Vec, PushBack, Range, LValue
///
#define VecPushBackArrL(v, arr, count) VecInsertRangeL((v), (arr), (v)->length, (count))
///
- In
Insert.h:315:
/// TAGS: Vec, PushFront, Range, LValue
///
#define VecPushFrontArrL(v, arr, count) VecInsertRangeL((v), (arr), 0, (count))
///
- In
Insert.h:657:
#define VecMustInsertRangeL(v, varr, idx, count) \
do { \
if (!VecInsertRangeL((v), (varr), (idx), (count))) { \
LOG_FATAL("VecMustInsertRangeL failed"); \
} \- In
Insert.h:500:
/// TAGS: Str, Insert, Range, LValue
///
#define StrInsertRangeL(str, varr, idx, count) VecInsertRangeL((str), (varr), (idx), (count))
///
Last updated on