Debian Codegraph @

converter/other/fiasco/lib/list.h

raw
1 /*
2 * list.h
3 *
4 * Written by: Ullrich Hafner
5 *
6 * This file is part of FIASCO (Fractal Image And Sequence COdec)
7 * Copyright (C) 1994-2000 Ullrich Hafner
8 */
9
10 /*
11 * $Date: 2000/06/14 20:49:37 $
12 * $Author: hafner $
13 * $Revision: 5.1 $
14 * $State: Exp $
15 */
16
17 #ifndef _LIST_H
18 #define _LIST_H
19
20 #include <stdio.h>
21 #include <stddef.h>
22
23 typedef struct node
24 {
25 struct node *prev; /* pointer to prev list element */
26 struct node *next; /* pointer to next list element */
27 void *value; /* pointer to value of node */
28 } node_t;
29
30 typedef struct list
31 {
32 node_t *head;
33 node_t *tail;
34 size_t size_of_element; /* number of bytes to store value */
35 } list_t;
36
37 typedef enum {TAIL, HEAD} pos_e;
38
39 /*
40 * Alias definitions for queue and stack
41 */
42
43 typedef list_t lqueue_t ;
44 #define alloc_queue alloc_list
45 #define free_queue free_list
46 #define queue_append(q, d) (list_insert ((q), TAIL, (d)))
47 #define queue_remove(q, d) (list_remove ((q), HEAD, (d)))
48
49 typedef list_t lstack_t ;
50 #define alloc_stack alloc_list
51 #define free_stack free_list
52 #define stack_push(q, d) (list_insert ((q), TAIL, (d)))
53 #define stack_pop(q, d) (list_remove ((q), TAIL, (d)))
54
55 list_t *
56 alloc_list (size_t size_of_element);
57 void
58 free_list (list_t *list);
59 bool_t
60 list_element_n (const list_t *list, pos_e pos, unsigned n, void *data);
61 void
62 list_foreach (const list_t *list, void (*function)(void *, void *),
63 void *data);
64 void
65 list_insert (list_t *list, pos_e pos, const void *data);
66 bool_t
67 list_remove (list_t *list, pos_e pos, void *data);
68 unsigned
69 list_sizeof (const list_t *list);
70
71 #endif /* not _LIST_H */
72