[Bf-blender-cvs] [f1edf3d0665] temp-inplace-priority-queue: cleanup

Jacques Lucke noreply at git.blender.org
Tue Dec 15 23:03:42 CET 2020


Commit: f1edf3d0665f8e805b4bbfdd13654fe5329d4416
Author: Jacques Lucke
Date:   Tue Dec 15 23:03:30 2020 +0100
Branches: temp-inplace-priority-queue
https://developer.blender.org/rBf1edf3d0665f8e805b4bbfdd13654fe5329d4416

cleanup

===================================================================

M	source/blender/blenlib/BLI_inplace_priority_queue.hh

===================================================================

diff --git a/source/blender/blenlib/BLI_inplace_priority_queue.hh b/source/blender/blenlib/BLI_inplace_priority_queue.hh
index f869d1f3f06..5aa2bba4bfa 100644
--- a/source/blender/blenlib/BLI_inplace_priority_queue.hh
+++ b/source/blender/blenlib/BLI_inplace_priority_queue.hh
@@ -25,7 +25,10 @@ namespace blender {
  * An InplacePriorityQueue adds priority queue functionality to an existing array. The underlying
  * array is not changed. Instead, the priority queue maintains indices into the original array.
  *
- * The priority queue provides efficient access to the element with the highest priority.
+ * The priority queue provides efficient access to the element in order of their priorities.
+ *
+ * When a priority changes, the priority queue has to be informed using one of the following
+ * methods: #priority_decreased, #priority_increased or #priority_changed.
  */
 template<typename T, typename FirstHasHigherPriority = std::greater<T>>
 class InplacePriorityQueue {
@@ -137,7 +140,10 @@ class InplacePriorityQueue {
   void priority_decreased(const int64_t index)
   {
     const int64_t heap_index = orig_to_heap_[index];
-    BLI_assert(heap_index < heap_size_);
+    if (heap_index >= heap_size_) {
+      /* This element is not in the queue currently. */
+      return;
+    }
     this->heapify(heap_index, heap_size_);
   }
 
@@ -148,7 +154,10 @@ class InplacePriorityQueue {
   void priority_increased(const int64_t index)
   {
     int64_t current = orig_to_heap_[index];
-    BLI_assert(current < heap_size_);
+    if (current >= heap_size_) {
+      /* This element is not in the queue currently. */
+      return;
+    }
     while (true) {
       if (current == 0) {
         break;



More information about the Bf-blender-cvs mailing list