libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
Loading...
Searching...
No Matches
avl.h
Go to the documentation of this file.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef _ACF_UTILS_AVL_H_
27#define _ACF_UTILS_AVL_H_
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <sys/types.h>
34#include "types.h"
35
36#define _AVL_IMPL_INCLUDED_FROM_AVL_H
37#include "avl_impl.h"
38
108typedef struct avl_tree avl_tree_t;
109
113typedef struct avl_node avl_node_t;
114
119typedef uintptr_t avl_index_t;
120
121
125#define AVL_BEFORE (0)
129#define AVL_AFTER (1)
130
131
132/*
133 * Prototypes
134 *
135 * Where not otherwise mentioned, "void *" arguments are a pointer to the
136 * user data structure which must contain a field of type avl_node_t.
137 *
138 * Also assume the user data structures looks like:
139 * stuct my_type {
140 * ...
141 * avl_node_t my_link;
142 * ...
143 * };
144 */
145
155API_EXPORT extern void avl_create(avl_tree_t *tree,
156 int (*compar) (const void *, const void *), size_t size, size_t offset);
157
158
169API_EXPORT extern void *avl_find(const avl_tree_t *tree, const void *node,
170 avl_index_t *where);
171
178API_EXPORT extern void avl_insert(avl_tree_t *tree, void *node,
179 avl_index_t where);
180
192API_EXPORT extern void avl_insert_here(avl_tree_t *tree, void *new_data,
193 void *here, int direction);
194
195
200API_EXPORT extern void *avl_first(const avl_tree_t *tree);
205API_EXPORT extern void *avl_last(const avl_tree_t *tree);
206
212#define AVL_NEXT(tree, node) avl_walk(tree, node, AVL_AFTER)
218#define AVL_PREV(tree, node) avl_walk(tree, node, AVL_BEFORE)
219
243API_EXPORT extern void *avl_nearest(const avl_tree_t *tree, avl_index_t where,
244 int direction);
245
246
255API_EXPORT extern void avl_add(avl_tree_t *tree, void *node);
256
257
263API_EXPORT extern void avl_remove(avl_tree_t *tree, void *node);
264
272API_EXPORT extern bool_t avl_update(avl_tree_t *, void *);
276API_EXPORT extern bool_t avl_update_lt(avl_tree_t *, void *);
280API_EXPORT extern bool_t avl_update_gt(avl_tree_t *, void *);
281
285API_EXPORT extern unsigned long avl_numnodes(const avl_tree_t *tree);
286
290API_EXPORT extern bool_t avl_is_empty(avl_tree_t *tree);
291
316API_EXPORT extern void *avl_destroy_nodes(avl_tree_t *tree, void **cookie);
317
318
324API_EXPORT extern void avl_destroy(avl_tree_t *tree);
325
326
327
328#ifdef __cplusplus
329}
330#endif
331
332#endif /* _ACF_UTILS_AVL_H_ */
void * avl_destroy_nodes(avl_tree_t *tree, void **cookie)
Definition avl.c:938
void * avl_last(const avl_tree_t *tree)
Definition avl.c:191
void avl_insert_here(avl_tree_t *tree, void *new_data, void *here, int direction)
Definition avl.c:561
void * avl_first(const avl_tree_t *tree)
Definition avl.c:172
uintptr_t avl_index_t
Definition avl.h:119
bool_t avl_update(avl_tree_t *, void *)
Definition avl.c:844
void avl_remove(avl_tree_t *tree, void *node)
Definition avl.c:660
bool_t avl_update_lt(avl_tree_t *, void *)
Definition avl.c:810
void * avl_nearest(const avl_tree_t *tree, avl_index_t where, int direction)
Definition avl.c:215
void avl_add(avl_tree_t *tree, void *node)
Definition avl.c:621
bool_t avl_is_empty(avl_tree_t *tree)
Definition avl.c:910
void avl_insert(avl_tree_t *tree, void *node, avl_index_t where)
Definition avl.c:471
void avl_create(avl_tree_t *tree, int(*compar)(const void *, const void *), size_t size, size_t offset)
Definition avl.c:867
unsigned long avl_numnodes(const avl_tree_t *tree)
Definition avl.c:903
bool_t avl_update_gt(avl_tree_t *, void *)
Definition avl.c:827
void avl_destroy(avl_tree_t *tree)
Definition avl.c:890
void * avl_find(const avl_tree_t *tree, const void *node, avl_index_t *where)
Definition avl.c:244