FirstNode

Gets the first node in a list.

Synopsis

Node *FirstNode( List *l )

Description

This macro returns a pointer to the first node in the specified list. If the list is empty, the macro returns 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 FirstNode in forward list traversal

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

Arguments

l
A pointer to the list from which to get the first node.

Return Value

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

Implementation

Macro implemented in list.h V20.

Associated Files

list.h
ANSI C Macro

See Also

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