NextNode

Gets the next node in a list.

Synopsis

Node *NextNode( const Node *n )

Description

This macro gets a pointer to the next node in a list. If the current node is the last node in the list, the result is a pointer to the tail (end-of-list) anchor. To determine if the return value is an actual node rather than the tail anchor, call the IsNode() procedure.

Example 1: Use of NextNode in forward list traversal

for (n = FirstNode( l ); IsNode( l, n ); n = NextNode( n )) 
{   . . .   }; 

Arguments

n
Pointer to the current node.

Return Value

The macro returns a pointer to the next node in the list or, if the current node is the last node in the list, to the tail (end-of-list) anchor.

Implementation

Macro implemented in list.h V20.

Associated Files

list.h
ANSI C Macro definition

Caveats

Assumes that n is a node in a list. If not, watch out.

See Also

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