ListForeachReverseInRange
- Macro
- October 8, 2025
Table of Contents
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)
- In
ListInt.c:334
:
if (start < end) {
int sum = 0;
ListForeachReverseInRange(list, item, start, end) {
sum += item;
}