从链接列表中删除指定的数据 [英] Delete specified data from linklist

查看:309
本文介绍了从链接列表中删除指定的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从LinkList删除数据,
通过检查条件,
是第一个节点,还是最后一个节点,还是介于它们之间?

How to delete data from LinkList,
By checking condition that,
is that a first node,or last node ,or inbetween

推荐答案



请参考以下文章,它将对您有很大帮助.

如何使用C/C ++创建链接列表
Hi,

Please referes the following article, it will help you a lot.

How to create Linked list using C/C++


您知道,删除链接列表中的项目只是更新指针的问题:
  • 找到要删除"节点.
  • 设置上一个"节点指向下一个"(如果列表是双链接的,则相反)
  • 释放已删除节点"的已分配内存.
You know, deleting an item in a linked list is just a matter of updating pointers:
  • find the ''to be deleted'' node.
  • set the ''previous'' node pointing to the ''next'' (and viceversa if the list is double linked).
  • release the allocated memory of the ''deleted node''.


在使用线程的情况下


如果有多个线程正在访问链接列表,那么您将必须格外小心.您将需要使用关键"部分.
In case of Threads


If multiple threads are accessing the linklist then you will have to take the special care. You will need to use Critical section.


这篇关于从链接列表中删除指定的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆