2024-03-10 20:11:25 +01:00
|
|
|
#ifndef _KIK_ZAD2_LINKED_LIST_H
|
|
|
|
#define _KIK_ZAD2_LINKED_LIST_H
|
|
|
|
|
2024-03-10 23:01:12 +01:00
|
|
|
#include <stdbool.h>
|
2024-03-10 20:11:25 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
typedef struct Node {
|
|
|
|
void *value;
|
|
|
|
struct Node *next;
|
|
|
|
} Node;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
size_t length;
|
|
|
|
size_t element_size;
|
|
|
|
Node *head;
|
2024-03-11 12:01:09 +01:00
|
|
|
Node *tail;
|
2024-03-10 20:11:25 +01:00
|
|
|
} LinkedList;
|
|
|
|
|
2024-03-10 22:56:05 +01:00
|
|
|
typedef struct {
|
|
|
|
bool success;
|
|
|
|
size_t comparisons;
|
|
|
|
} SearchResult;
|
|
|
|
|
2024-03-10 20:11:25 +01:00
|
|
|
LinkedList linked_list_new(size_t element_size);
|
|
|
|
|
2024-03-11 17:23:21 +01:00
|
|
|
// value is copied into a local queue-owned variable
|
|
|
|
// in rust terms - value is only borrowed
|
2024-03-10 20:11:25 +01:00
|
|
|
void linked_list_insert(LinkedList *l, void *value);
|
|
|
|
|
|
|
|
LinkedList linked_list_merge(LinkedList l1, LinkedList l2);
|
|
|
|
|
2024-03-10 22:56:05 +01:00
|
|
|
SearchResult linked_list_search(LinkedList l, void *value, int (*compare_values)(void *v1, void *v2));
|
|
|
|
|
2024-03-10 20:11:25 +01:00
|
|
|
#endif // _KIK_ZAD2_LINKED_LIST_H
|