You can remove the first node, the last node, or a specific node from a list. The following sections explain how to do it.
To remove the first node from a list, use the RemHead()
function:
Node *RemHead( List *l )
The l
argument is a pointer to the list from which you want to remove the node. The function returns a pointer to the node that was removed from the list or NULL if the list was empty.
To remove the last node from a list, use the RemTail()
function:
Node *RemTail( List *l )
The l
argument is a pointer to the list from which you want to remove the node. The function returns a pointer to the node that was removed from the list or NULL if the list was empty.
To remove a specific node from a list, use the RemNode()
function:
void RemNode( Node *n )
The n
argument is a pointer to the node you want to remove. Because a node can be only in one list, the node is automatically removed from the correct list.