PrevNode

Gets the previous node in a list.

Synopsis

Node *PrevNode( const Node *node )

Description

This macro returns a pointer to the previous node in a list. If the current node is the first node in the list, the result is a pointer to the head (beginning-of-list) anchor. To determine whether the return value is an actual node rather than the head anchor, use the IsNodeB() procedure.

Example 1: Use of PrevNode in reverse list traversal

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

Arguments

node
A pointer to the current node.

Return Value

The macro returns a pointer to the previous node in the list or, if the current node is the first node in the list, 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(), LastNode(), ScanList()