mirror of
https://github.com/Tilo-K/tstd.git
synced 2026-01-10 23:11:00 +00:00
feat: add contains functions
This commit is contained in:
12
list.c
12
list.c
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "tstd/list.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "helper.h"
|
||||
@@ -64,4 +65,13 @@ void* list_delete_element(list* list, int index) {
|
||||
list->data[i] = list->data[i + 1];
|
||||
}
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t list_contains(list* list, void* element) {
|
||||
for (int i = 0; i < list->length; i++) {
|
||||
if (list->data[i] == element) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user