Crossfire Server, Trunk  1.75.0
minheap.h
Go to the documentation of this file.
1 #ifndef MINHEAP_H
2 #define MINHEAP_H
3 
16 struct MinHeap {
18  void **arr;
20  int len;
22  int capacity;
25  int (*get_measure)(const void *);
29  void (*element_cleanup)(void *);
30 };
31 
32 MinHeap *minheap_init(int amt, int (*measure_func)(const void *), void (*cleanup_func)(void *));
33 void minheap_init_static(MinHeap *heap, void **arr, int amt, int (*measure_func)(const void *));
34 int minheap_insert(MinHeap *heap, void *ob);
35 void *minheap_remove(MinHeap *heap);
36 void minheap_free(MinHeap *to_free);
37 
38 #endif
MinHeap::capacity
int capacity
The capacity of the min-heap.
Definition: minheap.h:22
MinHeap::get_measure
int(* get_measure)(const void *)
Functon to get the measured quantity from the stored data.
Definition: minheap.h:25
MinHeap
In order to adequately path for A* search, we will need a minheap to efficiently handle pathing from ...
Definition: minheap.h:16
MinHeap::len
int len
The in-use length of the min-heap.
Definition: minheap.h:20
minheap_init
MinHeap * minheap_init(int amt, int(*measure_func)(const void *), void(*cleanup_func)(void *))
Function to intialize the minheap.
Definition: minheap.cpp:129
minheap_remove
void * minheap_remove(MinHeap *heap)
Pops the top of the minheap off.
Definition: minheap.cpp:209
minheap_init_static
void minheap_init_static(MinHeap *heap, void **arr, int amt, int(*measure_func)(const void *))
Initialize the minheap using statically allocated components.
Definition: minheap.cpp:162
minheap_insert
int minheap_insert(MinHeap *heap, void *ob)
Inserts an element into the min-heap.
Definition: minheap.cpp:184
minheap_free
void minheap_free(MinHeap *to_free)
Cleans the minheap.
Definition: minheap.cpp:226
MinHeap::element_cleanup
void(* element_cleanup)(void *)
Function pointer to clean up the elements.
Definition: minheap.h:29
MinHeap::arr
void ** arr
The heap array.
Definition: minheap.h:18