38 lines
940 B
C
38 lines
940 B
C
#ifndef _KIK_ZAD3_DOUBLY_LINKED_LIST_H
|
|
#define _KIK_ZAD3_DOUBLY_LINKED_LIST_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
typedef struct Node {
|
|
void *value;
|
|
struct Node *next;
|
|
struct Node *prev;
|
|
} Node;
|
|
|
|
typedef struct {
|
|
size_t length;
|
|
size_t element_size;
|
|
Node *head;
|
|
Node *tail;
|
|
} DoublyLinkedList;
|
|
|
|
typedef struct {
|
|
bool success;
|
|
size_t comparisons;
|
|
} SearchResult;
|
|
|
|
DoublyLinkedList doubly_linked_list_new(size_t element_size);
|
|
|
|
// value is copied into a local queue-owned variable
|
|
// in rust terms - value is only borrowed
|
|
void doubly_linked_list_insert(DoublyLinkedList *l, void *value);
|
|
|
|
DoublyLinkedList doubly_linked_list_merge(DoublyLinkedList l1, DoublyLinkedList l2);
|
|
|
|
// direction:
|
|
// - true = right
|
|
// - false = left
|
|
SearchResult doubly_linked_list_search(DoublyLinkedList l, void *value, bool direction, int (*compare_values)(void *v1, void *v2));
|
|
|
|
#endif // _KIK_ZAD3_DOUBLY_LINKED_LIST_H
|