Debian Codegraph @

Descent3/list.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * 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, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef LIST_H
20 #define LIST_H
21
22 #include "pstypes.h"
23 #include "pserror.h"
24
25 struct listnode {
26 void *data;
27 struct listnode *next;
28 struct listnode *prev;
29 };// listnode, list;
30
31 // Allocates space for a new list node
32 listnode *NewListNode(void);
33
34 // Adds an item to a list
35 int AddListItem(listnode **listp, void *item);
36
37 // Removes an item from a list
38 int RemoveListItem(listnode **listp, void *item);
39
40 // Destroys all the nodes in a list
41 // The items must be freed in another routine
42 void DestroyList(listnode **listp);
43
44 // Returns the number of items in a list
45 int CountListItems(listnode **listp);
46
47 // returns a pointer the given item index in a list
48 // Returns NULL if point not found
49 void *GetListItem(listnode **listp, int index);
50
51 // Returns how far from the head of the list a given item is
52 // Returns -1 if not found
53 int GetListItemIndex(listnode **listp, void *item);
54
55 #endif