]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/avl.h
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
10 typedef struct avlnode
{
11 struct avlnode
*avl_forw
; /* pointer to right child (> parent) */
12 struct avlnode
*avl_back
; /* pointer to left child (< parent) */
13 struct avlnode
*avl_parent
; /* parent pointer */
14 struct avlnode
*avl_nextino
; /* next in-order; NULL terminated list*/
15 char avl_balance
; /* tree balance */
21 typedef struct avlops
{
22 uintptr_t (*avl_start
)(avlnode_t
*);
23 uintptr_t (*avl_end
)(avlnode_t
*);
26 #define AVL_START(tree, n) (*(tree)->avl_ops->avl_start)(n)
27 #define AVL_END(tree, n) (*(tree)->avl_ops->avl_end)(n)
31 * root points to the root of the tree.
32 * firstino points to the first in the ordered list.
34 typedef struct avltree_desc
{
36 avlnode_t
*avl_firstino
;
41 /* possible values for avl_balance */
47 /* possible values for avl_flags */
49 #define AVLF_DUPLICITY 0x0001 /* no warnings on insert dups */
52 * 'Exported' avl tree routines
75 static inline avlnode_t
*
80 avlnode_t
*np
= tree
->avl_root
;
83 if (value
< AVL_START(tree
, np
)) {
87 if (value
>= AVL_END(tree
, np
)) {
91 ASSERT(AVL_START(tree
, np
) <= value
&&
92 value
< AVL_END(tree
, np
));
100 avltree_desc_t
*tree
,
105 avltree_desc_t
*tree
,
113 avltree_desc_t
*tree
,
119 avltree_desc_t
*tree
,
134 #define AVL_PRECEED 0x1
135 #define AVL_SUCCEED 0x2
137 #define AVL_INCLUDE_ZEROLEN 0x0000
138 #define AVL_EXCLUDE_ZEROLEN 0x0001
140 #endif /* __SYS_AVL_H__ */