24RCSIDH(minmax_heap_h,
"$Id: 5f56f2cfd090f76a733e70a59ade81f84ba75c4b $")
30#include <freeradius-devel/build.h>
31#include <freeradius-devel/missing.h>
32#include <freeradius-devel/util/misc.h>
33#include <freeradius-devel/util/talloc.h>
43#define FR_MINMAX_HEAP_TALLOC_HEADERS 2
72#define fr_minmax_heap_alloc(_ctx, _cmp, _type, _field, _init) \
73 _fr_minmax_heap_alloc(_ctx, _cmp, NULL, (size_t)offsetof(_type, _field), _init)
87#define fr_minmax_heap_talloc_alloc(_ctx, _cmp, _talloc_type, _field, _init) \
88 _fr_minmax_heap_alloc(_ctx, _cmp, #_talloc_type, (size_t)offsetof(_talloc_type, _field), _init)
97 return (heap_idx > 0);
126#define fr_minmax_heap_foreach(_hp, _type, _data) \
128 fr_minmax_heap_iter_t _iter; \
129 for (_type *_data = fr_minmax_heap_iter_init(_hp, &_iter); _data; _data = fr_minmax_heap_iter_next(_hp, &_iter))
131#ifndef TALLOC_GET_TYPE_ABORT_NOOP
133# define FR_MINMAX_HEAP_VERIFY(_hp) fr_minmax_heap_verify(__FILE__, __LINE__, _hp)
134#elif !defined(NDEBUG)
135# define FR_MINMAX_HEAP_VERIFY(_hp) fr_assert(_hp)
137# define FR_MINMAX_HEAP_VERIFY(_hp)
fr_minmax_heap_cmp_t cmp
Comparator function.
size_t offset
Offset of heap index in element structure.
fr_minmax_heap_t * _fr_minmax_heap_alloc(TALLOC_CTX *ctx, fr_minmax_heap_cmp_t cmp, char const *talloc_type, size_t offset, unsigned int init))
int fr_minmax_heap_insert(fr_minmax_heap_t *hp, void *data)
size_t fr_minmax_heap_pre_alloc_size(unsigned int count)
void * fr_minmax_heap_iter_next(fr_minmax_heap_t *hp, fr_minmax_heap_iter_t *iter)
Get the next entry in a minmax heap.
struct fr_minmax_heap_s * fr_minmax_heap_t
The main minmax heap structure Note that fr_minmax_heap_t is a pointer to fr_minmax_heap_s.
uint32_t fr_minmax_heap_num_elements(fr_minmax_heap_t *hp)
Return the number of elements in the minmax heap.
static bool fr_minmax_heap_entry_inserted(fr_minmax_heap_index_t heap_idx)
Check if an entry is inserted into a heap.
int fr_minmax_heap_min_pop(void **out, fr_minmax_heap_t *hp)
fr_cmp_ret_t(* fr_minmax_heap_cmp_t)(void const *a, void const *b)
Comparator to order elements.
int fr_minmax_heap_max_pop(void **out, fr_minmax_heap_t *hp)
void * fr_minmax_heap_min_peek(fr_minmax_heap_t *hp)
unsigned int fr_minmax_heap_iter_t
unsigned int fr_minmax_heap_index_t
void * fr_minmax_heap_iter_init(fr_minmax_heap_t *hp, fr_minmax_heap_iter_t *iter)
Iterate over entries in a minmax heap.
int fr_minmax_heap_extract(fr_minmax_heap_t *hp, void *data)
int fr_minmax_heap_max_peek(void **out, fr_minmax_heap_t *hp)
void fr_minmax_heap_verify(char const *file, int line, fr_minmax_heap_t const *hp)
fr_cmp_ret_t
Result of an ordering comparison.
init
Enter the EAP-IDENTITY state.
static size_t char ** out