|
| 1 | +/* |
| 2 | + * BreakHack - A dungeone crawler RPG |
| 3 | + * Copyright (C) 2025 Linus Probert <[email protected]> |
| 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 | +#ifndef _POS_HEAP_H_ |
| 19 | +#define _POS_HEAP_H_ |
| 20 | + |
| 21 | +#include "position.h" |
| 22 | +#include <stddef.h> |
| 23 | + |
| 24 | +typedef struct PHeap { |
| 25 | + Position *pos; |
| 26 | + size_t size; |
| 27 | + size_t capacity; |
| 28 | +} PHeap; |
| 29 | + |
| 30 | +/** |
| 31 | + * Initialize a PosHeap |
| 32 | + * |
| 33 | + * \param ph The heap to intialize |
| 34 | + */ |
| 35 | +void pheap_init(PHeap *ph); |
| 36 | + |
| 37 | +/** |
| 38 | + * Insert a new position into the heap |
| 39 | + * |
| 40 | + * \param ph The heap to modify |
| 41 | + * \param p The value to insert |
| 42 | + */ |
| 43 | +void pheap_insert(PHeap *ph, Position p); |
| 44 | + |
| 45 | +/** |
| 46 | + * Delete a position from a heap |
| 47 | + * |
| 48 | + * \param ph The heap to modify |
| 49 | + * \param p The position to delete |
| 50 | + */ |
| 51 | +void pheap_delete(PHeap *ph, Position p); |
| 52 | + |
| 53 | +/** |
| 54 | + * Peek the first position in the heap |
| 55 | + * |
| 56 | + * Peek the top position in the heap. Peeking an empty heap is undefined |
| 57 | + * behaviour. |
| 58 | + * |
| 59 | + * \param ph The heap to peek |
| 60 | + * \returns The top element in the heap |
| 61 | + */ |
| 62 | +Position pheap_peek(PHeap *ph); |
| 63 | + |
| 64 | +#endif // _POS_HEAP_H_ |
| 65 | + |
0 commit comments