linus的速删链表节点代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
void RemoveByValue(int value ,LinkNode ** head) {

for (LinkNode** curr = head;*curr ; )
{
LinkNode* entry = *curr;
if (entry->m_Value)
{
*curr = entry->m_Next; 通过改变一级指针间接改变二级指针的指向
free(entry);
}
else curr = &entry->m_Next;//点睛之笔二级指针的一级指针的地址,链表的next指针也属于一级指针
}

}
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

扫一扫,分享到微信

微信分享二维码
  • Copyrights © 2019-2024 kier Val
  • Visitors: | Views: