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

A

aredo3604gif

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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top