]> git.xonotic.org Git - xonotic/darkplaces.git/blob - com_list.h
Rename qboolean to qbool
[xonotic/darkplaces.git] / com_list.h
1 /*
2 Copyright (C) 2020 David "Cloudwalk" Knapp
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 // com_list.c - generic doubly linked list interface, inspired by Linux list.h
22
23 #include <stddef.h>
24
25 typedef struct llist_s
26 {
27         struct llist_s *prev;
28         struct llist_s *next;
29 } llist_t;
30
31 #define List_Head_Reset(name) { &(name), &(name) }
32
33 #define List_Container(ptr, type, member) ContainerOf(ptr, type, member)
34
35 #define List_ForEach(pos, head) \
36         for (pos = (head)->next; pos != (head); pos = pos->next)
37
38 #define List_ForEach_Prev(pos, head) \
39         for (pos = (head)->prev; pos != (head); pos = pos->prev)
40
41 void List_Add(llist_t *node, llist_t *start);
42 void List_Add_Tail(llist_t *node, llist_t *start);
43 void List_Delete(llist_t *node);
44 void List_Delete_Init(llist_t *node);
45 void List_Replace(llist_t *old, llist_t *_new);
46 void List_Swap(llist_t *node1, llist_t *node2);
47 void List_Move(llist_t *list, llist_t *start);
48 void List_Move_Tail(llist_t *list, llist_t *start);
49 void List_Bulk_Move_Tail(llist_t *start, llist_t *first, llist_t *last);
50 void List_Rotate_Left(llist_t *head);
51 void List_Rotate_To_Front(llist_t *list, llist_t *head);
52 void List_Splice(const llist_t *list, llist_t *head);
53 void List_Splice_Tail(const llist_t *list, llist_t *head);
54 qbool List_IsFirst(llist_t *list, llist_t *start);
55 qbool List_IsLast(llist_t *list, llist_t *start);
56 qbool List_IsEmpty(const llist_t *list);