Skip to content
ListForeachReverseInRange

ListForeachReverseInRange

ListForeachReverseInRange

Description

Iterate over each element var of the given list l in reverse, limited to index range [start, end) relative to the tail of the list. Index 0 corresponds to the tail, 1 to the previous node, and so on.

The variable var is declared and defined by this macro.

Since linked lists do not support indexing, this macro counts nodes from the tail and includes only those where the relative reverse index lies in [start, end).

Parameters

Name Direction Description
l in List to iterate over.
var in,out Name of the variable to be used which will contain the value of the current element during iteration.
start in Starting index from tail (inclusive).
end in Ending index from tail (exclusive).

Usage example (Cross-references)

Usage examples (Cross-references)
                    if (start < end) {
                        int sum = 0;
                        ListForeachReverseInRange(list, item, start, end) {
                            sum += item;
                        }
Last updated on