• Home
  • Raw
  • Download

Lines Matching refs:heap

40 struct heap {  struct
50 HEAP_EXPORT(void heap_init(struct heap* heap)); argument
51 HEAP_EXPORT(struct heap_node* heap_min(const struct heap* heap));
52 HEAP_EXPORT(void heap_insert(struct heap* heap,
55 HEAP_EXPORT(void heap_remove(struct heap* heap,
58 HEAP_EXPORT(void heap_dequeue(struct heap* heap, heap_compare_fn less_than));
62 HEAP_EXPORT(void heap_init(struct heap* heap)) { in HEAP_EXPORT() argument
63 heap->min = NULL; in HEAP_EXPORT()
64 heap->nelts = 0; in HEAP_EXPORT()
67 HEAP_EXPORT(struct heap_node* heap_min(const struct heap* heap)) { in HEAP_EXPORT() argument
68 return heap->min; in HEAP_EXPORT()
72 static void heap_node_swap(struct heap* heap, in heap_node_swap() argument
99 heap->min = child; in heap_node_swap()
106 HEAP_EXPORT(void heap_insert(struct heap* heap, in HEAP_EXPORT() argument
123 for (k = 0, n = 1 + heap->nelts; n >= 2; k += 1, n /= 2) in HEAP_EXPORT()
127 parent = child = &heap->min; in HEAP_EXPORT()
141 heap->nelts += 1; in HEAP_EXPORT()
147 heap_node_swap(heap, newnode->parent, newnode); in HEAP_EXPORT()
150 HEAP_EXPORT(void heap_remove(struct heap* heap, in HEAP_EXPORT() argument
160 if (heap->nelts == 0) in HEAP_EXPORT()
167 for (k = 0, n = heap->nelts; n >= 2; k += 1, n /= 2) in HEAP_EXPORT()
171 max = &heap->min; in HEAP_EXPORT()
181 heap->nelts -= 1; in HEAP_EXPORT()
189 if (child == heap->min) { in HEAP_EXPORT()
190 heap->min = NULL; in HEAP_EXPORT()
209 heap->min = child; in HEAP_EXPORT()
228 heap_node_swap(heap, child, smallest); in HEAP_EXPORT()
236 heap_node_swap(heap, child->parent, child); in HEAP_EXPORT()
239 HEAP_EXPORT(void heap_dequeue(struct heap* heap, heap_compare_fn less_than)) { in HEAP_EXPORT() argument
240 heap_remove(heap, heap->min, less_than); in HEAP_EXPORT()