diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-10-29 07:25:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-10-29 07:47:06 +0300 |
commit | 34257329263c3af108736b8d1047d48091e82d92 (patch) | |
tree | 29307361dce6c7bfced0b7b0887278df3c00b568 /source/blender/blenlib/BLI_heap.h | |
parent | 336885bebaa8c7b60041b139f02a29da475cf3ea (diff) |
BLI_heap: minor changes to the API
Recent addition of 'reinsert' didn't match logic for ghash API.
Rename to BLI_heap_node_value_update,
also add BLI_heap_insert_or_update since it's a common operation.
Diffstat (limited to 'source/blender/blenlib/BLI_heap.h')
-rw-r--r-- | source/blender/blenlib/BLI_heap.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h index cf18dfa5d2e..f7c1fd26985 100644 --- a/source/blender/blenlib/BLI_heap.h +++ b/source/blender/blenlib/BLI_heap.h @@ -44,12 +44,12 @@ void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp) ATTR_NONNULL(1); * duplicate values are allowed. */ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr) ATTR_NONNULL(1); +/* Insert or update */ +void BLI_heap_insert_or_update(Heap *heap, HeapNode **node_p, float value, void *ptr) ATTR_NONNULL(1, 2); + /* Remove a heap node. */ void BLI_heap_remove(Heap *heap, HeapNode *node) ATTR_NONNULL(1, 2); -/* Set new value for existing node. */ -void BLI_heap_reinsert(Heap *heap, HeapNode *node, float value); - /* Return 0 if the heap is empty, 1 otherwise. */ bool BLI_heap_is_empty(Heap *heap) ATTR_NONNULL(1); @@ -62,6 +62,10 @@ HeapNode *BLI_heap_top(Heap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) /* Pop the top node off the heap and return it's pointer. */ void *BLI_heap_popmin(Heap *heap) ATTR_NONNULL(1); +/* Update the priority in the heap (may be slow but generally faster than remove/insert). */ +void BLI_heap_node_value_update(Heap *heap, HeapNode *node, float value) ATTR_NONNULL(1, 2); +void BLI_heap_node_value_update_ptr(Heap *heap, HeapNode *node, float value, void *ptr) ATTR_NONNULL(1, 2); + /* Return the value or pointer of a heap node. */ float BLI_heap_node_value(HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); void *BLI_heap_node_ptr(HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); |