initialise heap
| 178 | |
| 179 | // initialise heap |
| 180 | void Heap_init |
| 181 | ( |
| 182 | heap_t *hp, // heap to initialise |
| 183 | heap_cmp cmp, // cmp Callback used to get an item's priority |
| 184 | void *udata, // udata User data passed through to cmp callback |
| 185 | unsigned int size // size Initial size of the heap's array |
| 186 | ) { |
| 187 | hp->cmp = cmp; |
| 188 | hp->size = size; |
| 189 | hp->count = 0; |
| 190 | hp->udata = udata; |
| 191 | } |
| 192 | |
| 193 | // add item, ensures that the data structure can hold the item |
| 194 | // NOTE: realloc() possibly called |