Lines Matching refs:heap
65 heap_print(const heap_t *heap) { in heap_print() argument
68 malloc_printf("vvv heap %p vvv\n", heap); in heap_print()
69 if (heap->ph_root == NULL) { in heap_print()
73 node_print(heap->ph_root, 0); in heap_print()
75 for (auxelm = phn_next_get(node_t, link, heap->ph_root); auxelm != NULL; in heap_print()
84 malloc_printf("^^^ heap %p ^^^\n", heap); in heap_print()
116 heap_validate(const heap_t *heap) { in heap_validate() argument
120 if (heap->ph_root == NULL) { in heap_validate()
124 nnodes += node_validate(heap->ph_root, NULL); in heap_validate()
126 for (auxelm = phn_next_get(node_t, link, heap->ph_root); auxelm != NULL; in heap_validate()
136 heap_print(heap); in heap_validate()
142 heap_t heap; in TEST_BEGIN() local
144 heap_new(&heap); in TEST_BEGIN()
145 assert_true(heap_empty(&heap), "Heap should be empty"); in TEST_BEGIN()
146 assert_ptr_null(heap_first(&heap), "Unexpected node"); in TEST_BEGIN()
147 assert_ptr_null(heap_any(&heap), "Unexpected node"); in TEST_BEGIN()
152 node_remove(heap_t *heap, node_t *node) { in node_remove() argument
153 heap_remove(heap, node); in node_remove()
159 node_remove_first(heap_t *heap) { in node_remove_first() argument
160 node_t *node = heap_remove_first(heap); in node_remove_first()
166 node_remove_any(heap_t *heap) { in node_remove_any() argument
167 node_t *node = heap_remove_any(heap); in node_remove_any()
178 heap_t heap; in TEST_BEGIN() local
205 heap_new(&heap); in TEST_BEGIN()
206 assert_u_eq(heap_validate(&heap), 0, in TEST_BEGIN()
215 heap_insert(&heap, &nodes[k]); in TEST_BEGIN()
217 assert_ptr_not_null(heap_any(&heap), in TEST_BEGIN()
220 assert_ptr_not_null(heap_first(&heap), in TEST_BEGIN()
223 assert_u_eq(heap_validate(&heap), k + 1, in TEST_BEGIN()
227 assert_false(heap_empty(&heap), in TEST_BEGIN()
234 assert_u_eq(heap_validate(&heap), j - k, in TEST_BEGIN()
236 node_remove(&heap, &nodes[k]); in TEST_BEGIN()
237 assert_u_eq(heap_validate(&heap), j - k in TEST_BEGIN()
243 node_remove(&heap, &nodes[k-1]); in TEST_BEGIN()
244 assert_u_eq(heap_validate(&heap), k - 1, in TEST_BEGIN()
251 node_t *node = node_remove_first(&heap); in TEST_BEGIN()
252 assert_u_eq(heap_validate(&heap), j - k in TEST_BEGIN()
265 node_t *node = heap_first(&heap); in TEST_BEGIN()
266 assert_u_eq(heap_validate(&heap), j - k, in TEST_BEGIN()
273 node_remove(&heap, node); in TEST_BEGIN()
274 assert_u_eq(heap_validate(&heap), j - k in TEST_BEGIN()
281 node_remove_any(&heap); in TEST_BEGIN()
282 assert_u_eq(heap_validate(&heap), j - k in TEST_BEGIN()
288 node_t *node = heap_any(&heap); in TEST_BEGIN()
289 assert_u_eq(heap_validate(&heap), j - k, in TEST_BEGIN()
291 node_remove(&heap, node); in TEST_BEGIN()
292 assert_u_eq(heap_validate(&heap), j - k in TEST_BEGIN()
300 assert_ptr_null(heap_first(&heap), in TEST_BEGIN()
302 assert_ptr_null(heap_any(&heap), in TEST_BEGIN()
304 assert_true(heap_empty(&heap), "Heap should be empty"); in TEST_BEGIN()