aisd_lab/lab1/zad2/include/linked_list.h

35 lines
760 B
C
Raw Normal View History

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;
Node *tail;
2024-03-10 20:11:25 +01:00
} LinkedList;
typedef struct {
bool success;
size_t comparisons;
} SearchResult;
2024-03-10 20:11:25 +01:00
LinkedList linked_list_new(size_t element_size);
// 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);
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