Bump to release 1.4.0
[smenu.git] / list.h
blobee897b7c0228b9d1296b0b3e734d0f8dcdb1def5
1 /* ################################################################### */
2 /* Copyright 2015, Pierre Gentile (p.gen.progs@gmail.com) */
3 /* */
4 /* This Source Code Form is subject to the terms of the Mozilla Public */
5 /* License, v. 2.0. If a copy of the MPL was not distributed with this */
6 /* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
7 /* ################################################################### */
9 #ifndef LIST_H
10 #define LIST_H
12 typedef struct ll_node_s ll_node_t;
13 typedef struct ll_s ll_t;
15 /* ******************************* */
16 /* Linked list specific structures */
17 /* ******************************* */
19 /* Linked list node structure */
20 /* """""""""""""""""""""""""" */
21 struct ll_node_s
23 void *data;
24 struct ll_node_s *next;
25 struct ll_node_s *prev;
28 /* Linked List structure */
29 /* """"""""""""""""""""" */
30 struct ll_s
32 ll_node_t *head;
33 ll_node_t *tail;
34 long len;
37 ll_t *
38 ll_new(void);
40 void
41 ll_init(ll_t *list);
43 ll_node_t *
44 ll_new_node(void);
46 void
47 ll_append(ll_t * const list, void * const data);
49 void
50 ll_sort(ll_t *list,
51 int (*comp)(void const *, void const *),
52 void (*swap)(void **, void **));
54 int
55 ll_delete(ll_t * const list, ll_node_t *node);
57 ll_node_t *
58 ll_find(ll_t * const, void * const, int (*)(void const *, void const *));
60 void
61 ll_free(ll_t * const list, void (*clean)(void *));
63 void
64 ll_destroy(ll_t *list, void (*clean)(void *));
66 #endif