一、单链表结构定义
typedef int linkType; ///< 定义链表结点数据域数据类型
/// @brief 链表结点定义
typedef struct t_linkNode
{
struct t_linkNode* pnext; ///< 结点指针域
linkType data; ///< 结点数据域
}myLNode;
/// @brief 链表结构定义
typedef struct t_linkList
{
myLNode* phead; //< 链表头结点
}myLinkList;
二、头删法
/// @brief 删除链表首元结点,即头删法
/// @param plist 链表指针
/// @return 返回是否删除成功标志
/// @retval ERROR(0):链表不存在或链表为空,不可操作
/// @retval OK(1):删除成功
status xxx_pop_front(myLinkList* plist)
{
if (plist == NULL)
{
return ERROR;
}
return xxx_pop_front_(plist->phead);
}
status xxx_pop_front_(myLNode* phead)
{
if (phead == NULL || phead->pnext == NULL)
{
return ERROR;
}
myLNode* pdel = phead->pnext;
phead->pnext = pdel->pnext;
pdel->pnext = NULL;
free(pdel);
pdel = NULL;
return OK;
}
标签:结点,单链,表首,链表,phead,pdel,NULL,pnext From: https://www.cnblogs.com/kxwslmsps/p/17120787.html