Skip to content
VecForeachInRange

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)

Usage examples (Cross-references)
                    if (start < end) {
                        size_t total_len = 0;
                        VecForeachInRange(vec, str, start, end) {
                            total_len += strlen(str);
                        }
                    if (start < end) {
                        size_t total_len = 0;
                        VecForeachInRange(vec, str, start, end) {
                            total_len += ZstrLen(str.data);
                        }
                    if (start < end) {
                        int sum = 0;
                        VecForeachInRange(vec, item, start, end) {
                            sum += item;
                        }
    /// end[in]      : Ending index (exclusive).
    ///
    #define StrForeachInRange(str, chr, start, end) VecForeachInRange((str), (chr), (start), (end))
    
    ///
Last updated on