By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,369 Members | 1,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,369 IT Pros & Developers. It's quick & easy.

[Need Help] to write a function to remove all matching nodes from a linked list...

P: n/a
I have coded a serie of singly linked lists in ANSI C which I have to
use.
The lists are then stored in a serie of buckets with chained hash
table technique.
In the various lists there are nodes that carry the same type of data
in some of their node fields and some don't. In the various nodes ,
the struct datatype, there is a flag set to 1 for items that I need to
remove. In the removing condition I have to add another match with an
internal data field in the node.

Now, what I need is a working code to pass the function the **head of
the list taken from the bucket, then iterate down the list and remove
all matching items wherever they could be down the list (which
obviously must include the condition of removing the whole list) and
finally ensure that dereferencing to the passed (*head) will have the
pointer in the bucket point to the correct new first item if needed
(since it could be removed). And have the list in a fully working
final state with only the items to be removed as per-search conditions
not there anymore.

I could write functions to add a node at the head, to destroy the
whole list, to update fields in node and find data but I can't code
this function and I need a working code to look at or to use directly
with little changes to matching conditions while iterating down the
list.

Could anyone please help me ?
Nov 14 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.