core-lightning/plugins/renepay/dijkstra.h
Rusty Russell b5da85e85d plugins/renepay/dijkstra: improve API to remove global.
The global is an *internal* hack because dijkstra_item_mover doesn't
take a context arg!  It should be used with care.

Easy, since all the accessors exist: we just hand in the struct dijkstra.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-31 12:58:56 +09:30

31 lines
1.1 KiB
C

#ifndef LIGHTNING_PLUGINS_RENEPAY_DIJKSTRA_H
#define LIGHTNING_PLUGINS_RENEPAY_DIJKSTRA_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
#include <gheap.h>
/* Allocation of resources for the heap. */
struct dijkstra *dijkstra_new(const tal_t *ctx, size_t max_num_nodes);
/* Initialization of the heap for a new Dijkstra search. */
void dijkstra_init(struct dijkstra *dijkstra);
/* Inserts a new element in the heap. If node_idx was already in the heap then
* its distance value is updated. */
void dijkstra_update(struct dijkstra *dijkstra, u32 node_idx, s64 distance);
u32 dijkstra_top(const struct dijkstra *dijkstra);
bool dijkstra_empty(const struct dijkstra *dijkstra);
void dijkstra_pop(struct dijkstra *dijkstra);
const s64* dijkstra_distance_data(const struct dijkstra *dijkstra);
/* Number of elements on the heap. */
size_t dijkstra_size(const struct dijkstra *dijkstra);
/* Maximum number of elements the heap can host */
size_t dijkstra_maxsize(const struct dijkstra *dijkstra);
#endif /* LIGHTNING_PLUGINS_RENEPAY_DIJKSTRA_H */