2021-02-01 22:06:37 +00:00
|
|
|
#ifndef LIBFLINT_LL_H
|
|
|
|
#define LIBFLINT_LL_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2021-02-01 22:27:01 +00:00
|
|
|
typedef struct ListNode {
|
2021-02-01 22:06:37 +00:00
|
|
|
void* data;
|
|
|
|
struct ListNode* next;
|
|
|
|
struct ListNode* prev;
|
2021-02-01 22:27:01 +00:00
|
|
|
} ListNode;
|
2021-02-01 22:06:37 +00:00
|
|
|
|
2021-02-01 22:27:01 +00:00
|
|
|
typedef struct {
|
2021-02-01 22:06:37 +00:00
|
|
|
size_t size;
|
|
|
|
|
|
|
|
void (*destroy)(void* data);
|
|
|
|
int (*match)(const void* a, const void* b);
|
|
|
|
|
|
|
|
struct ListNode* head;
|
|
|
|
struct ListNode* tail;
|
2021-02-01 22:27:01 +00:00
|
|
|
} List;
|
2021-02-01 22:06:37 +00:00
|
|
|
|
2021-02-01 22:27:01 +00:00
|
|
|
void ll_init(List* list, void (*destroy)(void *data));
|
|
|
|
void ll_destroy(List* list);
|
|
|
|
int ll_ins_next(List* list, ListNode* node, const void* data);
|
|
|
|
int ll_ins_prev(List* list, ListNode* node, const void* data);
|
|
|
|
int ll_remove(List* list, ListNode* node, void** data);
|
|
|
|
int ll_remove_next(List* list, ListNode* node, void** data);
|
|
|
|
int ll_remove_prev(List* list, ListNode* node, void** data);
|
2021-02-01 22:06:37 +00:00
|
|
|
|
|
|
|
#endif
|