VecInsertRangeR
Description
Insert a contiguous range of elements at the given index, preserving order. R-value form: the source range is treated as read-only input and is not zeroed.
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. |
Success
Returns true. The vector length grows by count; copies of the source elements now occupy indices [idx, idx + count); previous elements at and after idx have shifted right by count. The source range is untouched.
Failure
Returns false on allocation failure. The vector is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
VecInt.c:181:
values[i] = (i32)extract_u32(data, offset, data_size);
}
VecInsertRangeR(vec, values, idx, count);
}
break;- In
Vec.Insert.c:212:
// Push an array at a specific index
int values[] = {30, 40, 50};
VecInsertRangeR(&vec, values, 1, 3);
// Check length
- In
Vec.Insert.c:249:
// Insert range in the middle
VecInsertRangeR(&vec, VecBegin(&src), 1, VecLen(&src));
// Check length
- In
Insert.h:284:
/// TAGS: Vec, PushBack, Range, RValue
///
#define VecPushBackArrR(v, arr, count) VecInsertRangeR((v), (arr), (v)->length, (count))
///
- In
Insert.h:327:
/// TAGS: Vec, PushFront, Range, RValue
///
#define VecPushFrontArrR(v, arr, count) VecInsertRangeR((v), (arr), 0, (count))
///
- In
Insert.h:674:
#define VecMustInsertRangeR(v, varr, idx, count) \
do { \
if (!VecInsertRangeR((v), (varr), (idx), (count))) { \
LOG_FATAL("VecMustInsertRangeR failed"); \
} \- In
Insert.h:85:
#define StrInsertMany(...) OVERLOAD(StrInsertMany, __VA_ARGS__)
#define StrInsertMany_3(str, zstr, idx) \
_Generic((zstr), Zstr: VecInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrInsertMany_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)))- In
Insert.h:87:
_Generic((zstr), Zstr: VecInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrInsertMany_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)))
///
- In
Insert.h:523:
/// TAGS: Str, Insert, Range, RValue
///
#define StrInsertRangeR(str, varr, idx, count) VecInsertRangeR((str), (varr), (idx), (count))
///
Last updated on