Archived
1

Added search function

This commit is contained in:
2020-01-30 08:28:13 +01:00
parent 560ac1e59f
commit a95ee7387b
5 changed files with 51 additions and 11 deletions

View File

@ -86,6 +86,13 @@ Node* list_get(Node* head, unsigned index)
return head;
}
Node* list_search(Node* head, void* elem, int (*eq)(void*, void*))
{
while (head && !eq(elem, head->data))
head = head->next;
return head;
}
void list_remove(Node* node)
{
if (node->prev)

View File

@ -17,4 +17,6 @@ void list_insert(Node* prev_node, void* data);
Node* list_get(Node* head, unsigned index);
Node* list_search(Node* head, void* elem, int (*eq)(void*, void*));
void list_remove(Node* node);