From d3c815bd0831f46c18bb4bddc9f290b5f47e2c45 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sun, 4 Nov 2018 13:27:10 +0300 Subject: BLI_heap: add an API function to directly read the top node value. It is very commonly needed in loop conditions to check if the items in the heap are good enough to continue. --- source/blender/blenlib/intern/BLI_heap.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/blender/blenlib/intern/BLI_heap.c') diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index 5658c1fd103..17a15f93266 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -317,6 +317,17 @@ HeapNode *BLI_heap_top(const Heap *heap) return heap->tree[0]; } +/** + * Return the value of top node of the heap. + * This is the node with the lowest value. + */ +float BLI_heap_top_value(const Heap *heap) +{ + BLI_assert(heap->size != 0); + + return heap->tree[0]->value; +} + /** * Pop the top node off the heap and return it's pointer. */ -- cgit v1.2.3