62 return h->
heap[i - 1];
92 for (i = 1; i <= (h->
cur_len / 2); i++) {
102 if (r <= h->cur_len) {
239 if (!index || index > h->
cur_len) {
void * ast_heap_remove(struct ast_heap *h, void *elm)
Remove a specific element from a heap.
static ssize_t get_index(struct ast_heap *h, void *elm)
static void max_heapify(struct ast_heap *h, int i)
int __ast_heap_unlock(struct ast_heap *h, const char *file, const char *func, int line)
Unlock a heap.
void * __ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc
Asterisk main include file. File version handling, generic pbx functions.
static void * _ast_heap_remove(struct ast_heap *h, unsigned int index)
#define ast_rwlock_destroy(rwlock)
static void * heap_get(struct ast_heap *h, int i)
int __ast_rwlock_rdlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name)
int __ast_heap_rdlock(struct ast_heap *h, const char *file, const char *func, int line)
Read-Lock a heap.
int __ast_rwlock_unlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name)
int(* ast_heap_cmp_fn)(void *elm1, void *elm2)
Function type for comparing nodes in a heap.
struct ast_heap * ast_heap_destroy(struct ast_heap *h)
Destroy a max heap.
static int grow_heap(struct ast_heap *h, const char *file, int lineno, const char *func)
Add a row of additional storage for the heap.
size_t ast_heap_size(struct ast_heap *h)
Get the current size of a heap.
void * ast_heap_peek(struct ast_heap *h, unsigned int index)
Peek at an element on a heap.
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
static int parent_node(int i)
int ast_heap_verify(struct ast_heap *h)
Verify that a heap has been properly constructed.
void * __ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
void * ast_heap_pop(struct ast_heap *h)
Pop the max element off of the heap.
struct ast_heap * _ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, ssize_t index_offset, const char *file, int lineno, const char *func)
Create a max heap.
int __ast_rwlock_wrlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name)
static int right_node(int i)
static void heap_swap(struct ast_heap *h, int i, int j)
static int bubble_up(struct ast_heap *h, int i)
Structure for rwlock and tracking information.
Standard Command Line Interface.
int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func)
Push an element on to a heap.
static int left_node(int i)
static void heap_set(struct ast_heap *h, int i, void *elm)
int __ast_heap_wrlock(struct ast_heap *h, const char *file, const char *func, int line)
Write-Lock a heap.
void * __ast_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc