Skip to content
VecForeachInRangeIdx

VecForeachInRangeIdx

VecForeachInRangeIdx

Description

Iterate over elements in a specific range of the given vector v at each index idx. The variables var and idx are declared and defined by this macro.

idx will start from start and will go till end - 1

Parameters

Name Direction Description
v in,out Vector to iterate over.
var in Name of variable to be used which’ll contain value at iterated index idx.
idx in Name of variable to be used for iterating over indices.
start in Starting index (inclusive).
end in Ending index (exclusive).

Usage example (Cross-references)

Usage examples (Cross-references)
                    if (start < end) {
                        size_t total_len = 0;
                        VecForeachInRangeIdx(vec, str, idx, start, end) {
                            total_len += strlen(str) + idx;
                        }
                    if (start < end) {
                        size_t total_len = 0;
                        VecForeachInRangeIdx(vec, str, idx, start, end) {
                            total_len += ZstrLen(str.data) + idx;
                        }
                    if (start < end) {
                        int sum = 0;
                        VecForeachInRangeIdx(vec, item, idx, start, end) {
                            sum += item + (int)idx;
                        }
    /// TAGS: Foreach, Vec, Iteration, Loop, Range
    ///
    #define VecForeachInRange(v, var, start, end) VecForeachInRangeIdx((v), (var), (____iter___), (start), (end))
    
    ///
    /// end[in]      : Ending index (exclusive).
    ///
    #define StrForeachInRangeIdx(str, chr, idx, start, end) VecForeachInRangeIdx((str), (chr), idx, (start), (end))
    
    ///
Last updated on