aisd_lab/lab1/zad2/include/linked_list.h
2024-03-11 22:45:43 +01:00

34 lines
760 B
C

#ifndef _KIK_ZAD2_LINKED_LIST_H
#define _KIK_ZAD2_LINKED_LIST_H
#include <stdbool.h>
#include <stddef.h>
typedef struct Node {
void *value;
struct Node *next;
} Node;
typedef struct {
size_t length;
size_t element_size;
Node *head;
Node *tail;
} LinkedList;
typedef struct {
bool success;
size_t comparisons;
} SearchResult;
LinkedList linked_list_new(size_t element_size);
// value is copied into a local queue-owned variable
// in rust terms - value is only borrowed
void linked_list_insert(LinkedList *l, void *value);
LinkedList linked_list_merge(LinkedList l1, LinkedList l2);
SearchResult linked_list_search(LinkedList l, void *value, int (*compare_values)(void *v1, void *v2));
#endif // _KIK_ZAD2_LINKED_LIST_H