+ * 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.