-
Notifications
You must be signed in to change notification settings - Fork 50
/
list.h
66 lines (51 loc) · 1.5 KB
/
list.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* ################################################################### */
/* Copyright 2015, Pierre Gentile ([email protected]) */
/* */
/* This Source Code Form is subject to the terms of the Mozilla Public */
/* License, v. 2.0. If a copy of the MPL was not distributed with this */
/* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* ################################################################### */
#ifndef LIST_H
#define LIST_H
typedef struct ll_node_s ll_node_t;
typedef struct ll_s ll_t;
/* ******************************* */
/* Linked list specific structures */
/* ******************************* */
/* Linked list node structure */
/* """""""""""""""""""""""""" */
struct ll_node_s
{
void *data;
struct ll_node_s *next;
struct ll_node_s *prev;
};
/* Linked List structure */
/* """"""""""""""""""""" */
struct ll_s
{
ll_node_t *head;
ll_node_t *tail;
long len;
};
ll_t *
ll_new(void);
void
ll_init(ll_t *list);
ll_node_t *
ll_new_node(void);
void
ll_append(ll_t * const list, void * const data);
void
ll_sort(ll_t *list,
int (*comp)(void const *, void const *),
void (*swap)(void **, void **));
int
ll_delete(ll_t * const list, ll_node_t *node);
ll_node_t *
ll_find(ll_t * const, void * const, int (*)(void const *, void const *));
void
ll_free(ll_t * const list, void (*clean)(void *));
void
ll_destroy(ll_t *list, void (*clean)(void *));
#endif