LastNode

Gets the last node in a list.

Synopsis

Node *LastNode( const List *l )

Description

This macro returns a pointer to the last node in a list. If the list is empty, the macro returns a pointer to the head (beginning-of-list) anchor. To determine if the return value is an actual node rather than the head anchor, call the IsNodeB() procedure.

Example 1: Example 15-3 Use of LastNode in reverse list traversal

for (n = LastNode(list); IsNodeB(list, n); n = PrevNode( n )) 
{    . . .    }; 

Arguments

l
A pointer to the list structure to be examined.

Return Value

The macro returns a pointer to last node in the list or, if the list is empty, a pointer to the head (beginning-of-list) anchor.

Implementation

Macro implemented in list.h V20.

Associated Files

list.h
ANSI C Macro definition

See Also

FirstNode(), IsListEmpty(), IsNode(), IsNodeB(), NextNode(), PrevNode(), ScanList()