diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-10-28 20:42:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-10-28 20:42:58 +0300 |
commit | 4af1af70ad41015d0126837e856d87b930f61655 (patch) | |
tree | ba792d315f1400f2042b2d1b529beee85e7388d8 /source/blender/blenlib/intern/BLI_heap.c | |
parent | b84e3dc7f390c7b8251fb4d8c10557693157cd31 (diff) |
BLI_hash: add BLI_heap_reinsert
Allows avoiding remove/insert calls.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_heap.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_heap.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index 6b3d797a485..d794332b5df 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -306,6 +306,16 @@ void *BLI_heap_popmin(Heap *heap) return ptr; } +void BLI_heap_reinsert(Heap *heap, HeapNode *node, float value) +{ + if (value == node->value) { + return; + } + node->value = value; + heap_up(heap, node->index); + heap_down(heap, node->index); +} + void BLI_heap_remove(Heap *heap, HeapNode *node) { uint i = node->index; |