ListForeachPtrInRange
ListForeachPtrInRange
Description
This macro performs forward traversal, starting at index start (inclusive) and continuing until index end (exclusive), assuming zero-based indexing.
Since linked lists are not indexable, the traversal walks node-by-node and skips nodes before start, then continues while tracking the current index.
Parameters
| Name | Direction | Description |
|---|---|---|
l |
in,out | List to iterate over. |
var |
in,out | Name of the pointer variable to be used which will point to the current element during iteration. |
start |
in | Starting index (inclusive). |
end |
in | Ending index (exclusive). |
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ListInt.c:319:
if (start < end) {
int sum = 0;
ListForeachPtrInRange(list, item_ptr, start, end) {
sum += *item_ptr;
}
Last updated on