|
| pheap_t * | ph_create (uint max_nodes, pheap_comparator comparator, void *user_data) |
| | Create a pairing heap, which effectively maintains an efficient sorted ordering of nodes. The heap itself stores no user per-node state, it is expected that the user maintains a companion array. A comparator function must be provided so that the heap implementation can determine the relative ordering of nodes.
|
| void | ph_clear (pheap_t *heap) |
| | Removes all nodes from the pairing heap.
|
| void | ph_destroy (pheap_t *heap) |
| | De-allocates a pairing heap.
|
|
static pheap_node_t * | ph_get_node (pheap_t *heap, pheap_node_id_t id) |
|
static void | ph_add_child_node (pheap_t *heap, pheap_node_id_t parent_id, pheap_node_id_t child_id) |
|
static pheap_node_id_t | ph_merge_nodes (pheap_t *heap, pheap_node_id_t a, pheap_node_id_t b) |
| static pheap_node_id_t | ph_new_node (pheap_t *heap) |
| | Allocate a new node from the unused space in the heap.
|
| static pheap_node_id_t | ph_insert_node (pheap_t *heap, pheap_node_id_t id) |
| | Inserts a node into the heap.
|
| static pheap_node_id_t | ph_peek_head (pheap_t *heap) |
| | Returns the head node in the heap, i.e. the node which compares first, but without removing it from the heap.
|
| pheap_node_id_t | ph_remove_head (pheap_t *heap, bool free) |
| | Remove the head node from the pairing heap. This head node is the node which compares first in the logical ordering provided by the comparator.
|
| static pheap_node_id_t | ph_remove_and_free_head (pheap_t *heap) |
| | Remove the head node from the pairing heap. This head node is the node which compares first in the logical ordering provided by the comparator.
|
| bool | ph_remove_and_free_node (pheap_t *heap, pheap_node_id_t id) |
| | Remove and free an arbitrary node from the pairing heap. This is a more costly operation than removing the head via ph_remove_and_free_head().
|
| static bool | ph_contains_node (pheap_t *heap, pheap_node_id_t id) |
| | Determine if the heap contains a given node. Note containment refers to whether the node is inserted (ph_insert_node()) vs allocated (ph_new_node()).
|
| static void | ph_free_node (pheap_t *heap, pheap_node_id_t id) |
| | Free a node that is not currently in the heap, but has been allocated.
|
| void | ph_dump (pheap_t *heap, void(*dump_key)(pheap_node_id_t id, void *user_data), void *user_data) |
| | Print a representation of the heap for debugging.
|
| void | ph_post_alloc_init (pheap_t *heap, uint max_nodes, pheap_comparator comparator, void *user_data) |
| | Initialize a statically allocated heap (ph_create() using the C heap). The heap member nodes must be allocated of size max_nodes.
|