MCPcopy Create free account
hub / github.com/ElementsProject/lightning / priorityqueue_update

Function priorityqueue_update

plugins/askrene/child/priorityqueue.c:90–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void priorityqueue_update(struct priorityqueue *q, u32 key, s64 value) {
91 assert(key < priorityqueue_maxsize(q));
92
93 if (!q->heapptr[key]) {
94 /* not in the heap */
95 priorityqueue_append(q, key, value);
96 global_priorityqueue = q;
97 gheap_restore_heap_after_item_increase(
98 &q->gheap_ctx, q->base, q->heapsize,
99 q->heapptr[key] - q->base);
100 global_priorityqueue = NULL;
101 return;
102 }
103
104 if (q->value[key] > value) {
105 /* value decrease */
106 q->value[key] = value;
107
108 global_priorityqueue = q;
109 gheap_restore_heap_after_item_increase(
110 &q->gheap_ctx, q->base, q->heapsize,
111 q->heapptr[key] - q->base);
112 global_priorityqueue = NULL;
113 } else {
114 /* value increase */
115 q->value[key] = value;
116
117 global_priorityqueue = q;
118 gheap_restore_heap_after_item_decrease(
119 &q->gheap_ctx, q->base, q->heapsize,
120 q->heapptr[key] - q->base);
121 global_priorityqueue = NULL;
122 }
123 /* assert(gheap_is_heap(&q->gheap_ctx,
124 * q->base,
125 * priorityqueue_size())); */
126}
127
128u32 priorityqueue_top(const struct priorityqueue *q) {
129 assert(!priorityqueue_empty(q));

Callers 3

mainFunction · 0.85
dijkstra_pathFunction · 0.85
dijkstra_nearest_sinkFunction · 0.85

Calls 2

priorityqueue_maxsizeFunction · 0.85
priorityqueue_appendFunction · 0.85

Tested by 1

mainFunction · 0.68