+ * Decrease `heap[pos]` to a new value @elt (less or equal to the previous value).
+ * The time complexity is `O(log(n))`.
+ *
+ * Position tracking: Fully automatic.
+ **/
+#define HEAP_DECREASE(type,heap,num,less,swap,pos,elt) \
+ do { \
+ uns _j, _u; \
+ type x; \
+ heap[pos] = elt; \
+ _j = pos; \
+ HEAP_BUBBLE_UP_J(heap,num,less,swap); \
+ } while(0)
+
+/**
+ * Change `heap[pos]` to a new value @elt. The time complexity is `O(log(n))`.
+ * If you know that the new value is always smaller or always greater, it is faster
+ * to use `HEAP_DECREASE` or `HEAP_INCREASE` respectively.
+ *
+ * Position tracking: Fully automatic.
+ **/
+#define HEAP_REPLACE(type,heap,num,less,swap,pos,elt) \
+ do { \
+ type _elt = elt; \
+ if (less(heap[pos], _elt)) \
+ HEAP_INCREASE(type,heap,num,less,swap,pos,_elt); \
+ else \
+ HEAP_DECREASE(type,heap,num,less,swap,pos,_elt); \
+ } while(0)
+
+/**
+ * Replace the minimum `heap[pos]` by a new value @elt. The time complexity is `O(log(n))`.
+ *
+ * Position tracking: Fully automatic.
+ **/
+#define HEAP_REPLACE_MIN(type,heap,num,less,swap,elt) \
+ HEAP_INCREASE(type,heap,num,less,swap,1,elt)
+
+/**
+ * Delete an arbitrary element, given by its position. The @num variable is decremented.
+ * The operation takes `O(log(n))` time.
+ *
+ * Position tracking: Fully automatic.