VecForeachInRange
- Macro
- October 8, 2025
Table of Contents
VecForeachInRange
VecForeachInRange
Description
Iterate over elements in a specific range of the given vector v
. This is a convenience macro that iterates over a range using an internally managed index. The variable var
is declared and defined by this macro.
Parameters
Name | Direction | Description |
---|---|---|
v | in,out | Vector to iterate over. |
var | in | Name of variable to be used which’ll contain value of the current element. |
start | in | Starting index (inclusive). |
end | in | Ending index (exclusive). |
Usage example (Cross-references)
- In
Foreach.h:145
:
/// end[in] : Ending index (exclusive).
///
#define StrForeachInRange(str, chr, start, end) VecForeachInRange((str), (chr), (start), (end))
///
- In
VecInt.c:490
:
if (start < end) {
int sum = 0;
VecForeachInRange(vec, item, start, end) {
sum += item;
}
- In
VecStr.c:520
:
if (start < end) {
size_t total_len = 0;
VecForeachInRange(vec, str, start, end) {
total_len += ZstrLen(str.data);
}
- In
VecCharPtr.c:558
:
if (start < end) {
size_t total_len = 0;
VecForeachInRange(vec, str, start, end) {
total_len += strlen(str);
}