1 /* Double linked list support
2 
3    Copyright (C) 2016 Molnar Karoly
4 
5 This file is part of gputils.
6 
7 gputils is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11 
12 gputils is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with gputils; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21 
22 #ifndef __GPLIST_H__
23 #define __GPLIST_H__
24 
25 typedef void (*gp_node_del_t)(void *);
26 
27 #define GPNodeHeader(Type) \
28   Type         *prev;      \
29   Type         *next;      \
30   unsigned int  list_id
31 
32 #define GPListHeader(Type)  \
33   Type          *first;     \
34   Type          *curr;      \
35   Type          *last;      \
36   size_t         num_nodes; \
37   gp_node_del_t  node_del;  \
38   unsigned int   serial_id
39 
40 extern void *gp_list_node_new(size_t Item_size);
41 extern void gp_list_node_free(void *List, void *Node);
42 extern void *gp_list_node_append(void *List, void *Node);
43 extern void *gp_list_node_insert_after(void *List, void *Node, void *Node_new);
44 extern void *gp_list_node_insert_before(void *List, void *Node, void *Node_new);
45 extern void *gp_list_node_remove(void *List, void *Node);
46 extern void *gp_list_node_move(void *Dst, void *Src, void *Node);
47 extern void gp_list_node_delete(void *List, void *Node);
48 
49 extern void gp_list_set_delete_node_func(void *List, gp_node_del_t Function);
50 extern void **gp_list_make_block(void *List, size_t Num_nodes, size_t Item_size);
51 extern void gp_list_move(void *Dst, void *Src);
52 extern void *gp_list_clone_list(const void *List, int (Cmp_func)(const void *, const void *));
53 extern void gp_list_reset(void *List);
54 extern void gp_list_set_access_point(void *List, void *Node);
55 extern void gp_list_clear(void *List);
56 extern void gp_list_delete(void *List);
57 
58 #endif /* __GPLIST_H__ */
59