 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
37 return (index << 1) | 1;
48 return (index << 1) + 2;
60 return index ? (index - 1) >> 1 : -1;
81 while (at < heap->len) {
86 if (left >= heap->
len)
91 if (right < heap->len) {
103 if (val[0] <= (minchild == left ? val[1] : val[2]))
105 void *tmp = heap->
arr[at];
106 heap->
arr[at] = heap->
arr[minchild];
107 heap->
arr[minchild] = tmp;
133 newheap->
arr =
static_cast<void **
>(malloc(amt *
sizeof(
void *)));
189 int at = heap->
len++;
192 heap->
arr[at] = heap->
arr[parent];
212 void *removed = heap->
arr[0];
230 for (
int i = 0; i < to_free->
len; ++i)
int capacity
The capacity of the min-heap.
static int minheap_get_parent(int index)
Get the index of the parent in the heap.
int(* get_measure)(const void *)
Functon to get the measured quantity from the stored data.
In order to adequately path for A* search, we will need a minheap to efficiently handle pathing from ...
static void minheap_normalize(MinHeap *heap)
Normalize the minheap.
void minheap_free(MinHeap *to_free)
Cleans the minheap.
MinHeap * minheap_init(int amt, int(*measure_func)(const void *), void(*cleanup_func)(void *))
Function to intialize the minheap.
int len
The in-use length of the min-heap.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
void * minheap_remove(MinHeap *heap)
Pops the top of the minheap off.
void minheap_init_static(MinHeap *heap, void **arr, int amt, int(*measure_func)(const void *))
Initialize the minheap using statically allocated components.
void(* element_cleanup)(void *)
Function pointer to clean up the elements.
static int minheap_get_right(int index)
Get the index of the right child in the heap.
int minheap_insert(MinHeap *heap, void *ob)
Inserts an element into the min-heap.
void ** arr
The heap array.
static int minheap_get_left(int index)
Get the index of the left child in the heap.