Skip to content
ListForeachPtrReverseInRange

ListForeachPtrReverseInRange

ListForeachPtrReverseInRange

Description

Iterate over each element var (as a pointer) 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 as a pointer to the list’s data type.

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,out List to iterate over.
var out Name of the pointer variable to be used which will point to 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;
                        ListForeachPtrReverseInRange(list, item_ptr, start, end) {
                            sum += *item_ptr;
                        }
Last updated on