ftwin 0.8.10
napr_heap.h
Go to the documentation of this file.
1
6/*
7 * Copyright (C) 2007 François Pesce : francois.pesce (at) gmail (dot) com
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22#ifndef NAPR_HEAP_H
23#define NAPR_HEAP_H
24
28typedef struct napr_heap_t napr_heap_t;
29
38typedef int (napr_heap_cmp_callback_fn_t) (const void *, const void *);
39
44typedef void (napr_heap_del_callback_fn_t) (void *);
45
46
47#include <apr_pools.h>
62
70
77int napr_heap_insert(napr_heap_t *heap, void *datum);
78
85
94void *napr_heap_get_nth(const napr_heap_t *heap, unsigned int n);
95
101unsigned int napr_heap_size(const napr_heap_t *heap);
102
109int napr_heap_insert_r(napr_heap_t *heap, void *datum);
110
111#endif /* NAPR_HEAP_H */
void * napr_heap_extract(napr_heap_t *heap)
Removes and returns the element at the top of the heap (the min or max element).
Definition napr_heap.c:122
napr_heap_t * napr_heap_make(apr_pool_t *pool, napr_heap_cmp_callback_fn_t *cmp)
Creates a new heap.
Definition napr_heap.c:48
int napr_heap_insert(napr_heap_t *heap, void *datum)
Inserts an element into the heap, maintaining the heap property.
Definition napr_heap.c:70
napr_heap_t * napr_heap_make_r(apr_pool_t *pool, napr_heap_cmp_callback_fn_t *cmp)
Creates a new thread-safe heap.
Definition napr_heap.c:189
struct napr_heap_t napr_heap_t
Opaque heap structure.
Definition napr_heap.h:28
unsigned int napr_heap_size(const napr_heap_t *heap)
Gets the current number of elements in the heap.
Definition napr_heap.c:181
int() napr_heap_cmp_callback_fn_t(const void *, const void *)
Callback function to compare two elements in the heap.
Definition napr_heap.h:38
void * napr_heap_get_nth(const napr_heap_t *heap, unsigned int n)
Gets the element at a specific index in the heap's internal array.
Definition napr_heap.c:173
int napr_heap_insert_r(napr_heap_t *heap, void *datum)
Inserts an element into a thread-safe heap.
Definition napr_heap.c:204
void() napr_heap_del_callback_fn_t(void *)
Optional callback function to delete/deallocate an element when not using APR pools.
Definition napr_heap.h:44