VecForeachInRangeIdx

Table of Contents

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

NameDirectionDescription
vin,outVector to iterate over.
varinName of variable to be used which’ll contain value at iterated index idx.
idxinName of variable to be used for iterating over indices.
startinStarting index (inclusive).
endinEnding index (exclusive).

Success

The body is executed for each element of the vector v from the start index to the end-1 index.

Failure

If the vector v is NULL, its length is zero, or the range is invalid, the loop body will not be executed. Any access to an invalid index will result in a fatal log message and program termination.

Usage example (Cross-references)

    ///
    #define StrForeachInRangeIdx(str, chr, idx, start, end, body)                                                          \
    VecForeachInRangeIdx((str), (chr), idx, (start), (end), {body})
    
    ///
    ///
    #define VecForeachInRange(v, var, start, end, body)                                                                    \
    VecForeachInRangeIdx((v), (var), (____iter___), (start), (end), {body})
    
    ///

Share :