-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinked_list.h
More file actions
30 lines (26 loc) · 805 Bytes
/
Copy pathlinked_list.h
File metadata and controls
30 lines (26 loc) · 805 Bytes
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
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
typedef struct NODE {
void *data;
struct NODE *next;
struct NODE *prev;
} NODE;
typedef struct LINKED_LIST {
int size;
NODE *dummy_head;
NODE *dummy_tail;
int (*equal)(const void *a, const void *b);
} LINKED_LIST;
int add_tail(void *data, LINKED_LIST *list);
int add_head(void *data, LINKED_LIST *list);
void *pop_head(LINKED_LIST *list);
void *pop_tail(LINKED_LIST *list);
void *get_by_index(LINKED_LIST *list, int index);
void *get_by_value(LINKED_LIST *list, void *elem);
void *remove_elem(void *data_to_del, LINKED_LIST *list);
void swap(NODE *node1, NODE *node2);
int has_next(NODE **elem);
void *next(NODE **elem);
void list_clear(LINKED_LIST *list);
void list_init(LINKED_LIST **list, int (*equal)(const void *a, const void *b));
#endif