/*双链表的删除
** 把一个值插入到双链表,rootp是一个指向根节点的指针
** del 是指向欲移除节点的指针
** 返回值:
** 如果链表不包含移除的节点,函数就返回假,否则返回真。
*/
int dll_remove(Node *rootp, Node *del)
{
register Node *thist;
assert( del != NULL);
for(thist=rootp->fwd; thist != NULL; thist = thist->fwd)
if(thist == del)
break;
if(thist == del)
{
/*
** Update fwd pointer of the previous node.
*/
if( thist->bwd == NULL )
rootp->fwd = thist->fwd;
else
thist->bwd->fwd = thist->fwd;
/*
** Update bwd pointer of the next node.
*/
if( thist->fwd == NULL )
rootp->bwd = thist->bwd;
else
thist->fwd->bwd = thist->bwd;
free( thist );
return TRUE;
}
else
return FALSE;
}
C 语言实例11——双链表删除
猜你喜欢
转载自blog.csdn.net/qq_27762895/article/details/83243677
今日推荐
周排行