| 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_Hcxx . . $ `Descent3/list.h:20:9`! |
| 21 | |
| 22 | #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/ |
| 23 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 24 | |
| 25 | struct listnodecxx . . $ listnode# { |
| 26 | void *datacxx . . $ listnode#data.; |
| 27 | struct listnodecxx . . $ listnode# *nextcxx . . $ listnode#next.; |
| 28 | struct listnodecxx . . $ listnode# *prevcxx . . $ listnode#prev.; |
| 29 | };// listnode, list; |
| 30 | |
| 31 | // Allocates space for a new list node |
| 32 | listnodecxx . . $ listnode# *NewListNodecxx . . $ NewListNode(d74684795f1b3fc8).(void); |
| 33 | |
| 34 | // Adds an item to a list |
| 35 | int AddListItemcxx . . $ AddListItem(69ddacfa89c563ce).(listnodecxx . . $ listnode# **listp, void *item); |
| 36 | |
| 37 | // Removes an item from a list |
| 38 | int RemoveListItemcxx . . $ RemoveListItem(69ddacfa89c563ce).(listnodecxx . . $ listnode# **listp, void *item); |
| 39 | |
| 40 | // Destroys all the nodes in a list |
| 41 | // The items must be freed in another routine |
| 42 | void DestroyListcxx . . $ DestroyList(7102129d4b5eb48d).(listnodecxx . . $ listnode# **listp); |
| 43 | |
| 44 | // Returns the number of items in a list |
| 45 | int CountListItemscxx . . $ CountListItems(738f935373f69df8).(listnodecxx . . $ listnode# **listp); |
| 46 | |
| 47 | // returns a pointer the given item index in a list |
| 48 | // Returns NULL if point not found |
| 49 | void *GetListItemcxx . . $ GetListItem(559f24056c1df4cf).(listnodecxx . . $ 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 GetListItemIndexcxx . . $ GetListItemIndex(69ddacfa89c563ce).(listnodecxx . . $ listnode# **listp, void *item); |
| 54 | |
| 55 | #endif |