-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlist.h
41 lines (32 loc) · 909 Bytes
/
dlist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Copyright (C) 2016, CompuLab ltd.
* Author: Andrey Gelman <[email protected]>
* License: GNU GPLv2 or later, at your option
*/
/*
* Doubly Linked List
*/
#ifndef _DLIST_H
#define _DLIST_H
typedef int (*DListCompare)(void *inlist, void *outlist);
typedef struct DListNode {
struct DListNode *next;
struct DListNode *prev;
} DListNode;
typedef struct DList {
unsigned int count;
DListNode *head;
DListNode *tail;
DListCompare compare;
} DList;
DList *dlist_create(DListCompare compare);
void dlist_destroy(DList *list);
void dlist_push_back(DList *list, void *_node);
void dlist_push_ordered(DList *list, void *_node);
void *dlist_pop_front(DList *list);
void dlist_remove_node(DList *list, void *_node);
void *dlist_remove_ordered(DList *list, void *_node);
void *dlist_peek_front(DList *list);
bool dlist_is_empty(DList *list);
int dlist_test(void);
#endif /* _DLIST_H */