| 1 | /** |
| 2 | * collectd - src/utils_avltree.c |
| 3 | * Copyright (C) 2006,2007 Florian octo Forster |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be included in |
| 13 | * all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Florian octo Forster <octo at collectd.org> |
| 25 | **/ |
| 26 | |
| 27 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`! |
| 28 | #include "config.h"cxx . . $ `<file>/config.h`/ |
| 29 | #endif |
| 30 | |
| 31 | #include <assert.h> |
| 32 | #include <stdlib.h> |
| 33 | |
| 34 | #include "aircrack-ng/defs.h"cxx . . $ `<file>/include/aircrack-ng/defs.h`/ |
| 35 | #include "aircrack-ng/adt/avl_tree.h"cxx . . $ `<file>/include/aircrack-ng/adt/avl_tree.h`/ |
| 36 | |
| 37 | #define BALANCEcxx . . $ `lib/libac/adt/avl_tree.c:37:9`!(n) \ |
| 38 | (((n) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? 0 \ |
| 39 | : (((n)->left == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? 0 : (n)->left->height) \ |
| 40 | - (((n)->right == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? 0 : (n)->right->height)) |
| 41 | |
| 42 | /* |
| 43 | * private data types |
| 44 | */ |
| 45 | struct c_avl_node_scxx . . $ c_avl_node_s# |
| 46 | { |
| 47 | void * keycxx . . $ c_avl_node_s#key.; |
| 48 | void * valuecxx . . $ c_avl_node_s#value.; |
| 49 | |
| 50 | int heightcxx . . $ c_avl_node_s#height.; |
| 51 | struct c_avl_node_scxx . . $ c_avl_node_s# * leftcxx . . $ c_avl_node_s#left.; |
| 52 | struct c_avl_node_scxx . . $ c_avl_node_s# * rightcxx . . $ c_avl_node_s#right.; |
| 53 | struct c_avl_node_scxx . . $ c_avl_node_s# * parentcxx . . $ c_avl_node_s#parent.; |
| 54 | }; |
| 55 | typedef struct c_avl_node_scxx . . $ c_avl_node_s# c_avl_node_tcxx . . $ c_avl_node_t#; |
| 56 | |
| 57 | struct c_avl_tree_scxx . . $ c_avl_tree_s# |
| 58 | { |
| 59 | c_avl_node_tcxx . . $ c_avl_node_t# * rootcxx . . $ c_avl_tree_s#root.; |
| 60 | int (*comparecxx . . $ c_avl_tree_s#compare.)(const void *, const void *); |
| 61 | int sizecxx . . $ c_avl_tree_s#size.; |
| 62 | }; |
| 63 | |
| 64 | struct c_avl_iterator_scxx . . $ c_avl_iterator_s# |
| 65 | { |
| 66 | c_avl_tree_tcxx . . $ c_avl_tree_t# * treecxx . . $ c_avl_iterator_s#tree.; |
| 67 | c_avl_node_tcxx . . $ c_avl_node_t# * nodecxx . . $ c_avl_iterator_s#node.; |
| 68 | }; |
| 69 | |
| 70 | /* |
| 71 | * private functions |
| 72 | */ |
| 73 | #if 0 |
| 74 | static void verify_tree (c_avl_node_t *n) |
| 75 | { |
| 76 | if (n == NULL) |
| 77 | return; |
| 78 | |
| 79 | verify_tree (n->left); |
| 80 | verify_tree (n->right); |
| 81 | |
| 82 | assert ((BALANCE (n) >= -1) && (BALANCE (n) <= 1)); |
| 83 | assert ((n->parent == NULL) || (n->parent->right == n) || (n->parent->left == n)); |
| 84 | } /* void verify_tree */ |
| 85 | #else |
| 86 | #define verify_treecxx . . $ `lib/libac/adt/avl_tree.c:86:9`!(n) /**/ |
| 87 | #endif |
| 88 | |
| 89 | static void free_nodecxx . . $ free_node(d1670e8f11be7e69).(c_avl_node_tcxx . . $ c_avl_node_t# * n) |
| 90 | { |
| 91 | if (n == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return; |
| 92 | |
| 93 | if (n->leftcxx . . $ c_avl_node_s#left. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) free_nodecxx . . $ free_node(d1670e8f11be7e69).(n->leftcxx . . $ c_avl_node_s#left.); |
| 94 | if (n->rightcxx . . $ c_avl_node_s#right. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) free_nodecxx . . $ free_node(d1670e8f11be7e69).(n->rightcxx . . $ c_avl_node_s#right.); |
| 95 | |
| 96 | freecxx . . $ free(5d22bdacc48458e8).(n); |
| 97 | } |
| 98 | |
| 99 | static int calc_heightcxx . . $ calc_height(ddf8932c150c7635).(c_avl_node_tcxx . . $ c_avl_node_t# * n) |
| 100 | { |
| 101 | int height_left; |
| 102 | int height_right; |
| 103 | |
| 104 | if (n == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return 0; |
| 105 | |
| 106 | height_left = (n->leftcxx . . $ c_avl_node_s#left. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? 0 : n->leftcxx . . $ c_avl_node_s#left.->heightcxx . . $ c_avl_node_s#height.; |
| 107 | height_right = (n->rightcxx . . $ c_avl_node_s#right. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? 0 : n->rightcxx . . $ c_avl_node_s#right.->heightcxx . . $ c_avl_node_s#height.; |
| 108 | |
| 109 | return ((height_left > height_right) ? height_left : height_right) + 1; |
| 110 | } /* int calc_height */ |
| 111 | |
| 112 | static c_avl_node_tcxx . . $ c_avl_node_t# * searchcxx . . $ search(accc3d88632a864d).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, const void * key) |
| 113 | { |
| 114 | c_avl_node_tcxx . . $ c_avl_node_t# * n; |
| 115 | int cmp; |
| 116 | |
| 117 | n = t->rootcxx . . $ c_avl_tree_s#root.; |
| 118 | while (n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 119 | { |
| 120 | cmp = t->comparecxx . . $ c_avl_tree_s#compare.(key, n->keycxx . . $ c_avl_node_s#key.); |
| 121 | if (cmp == 0) |
| 122 | return n; |
| 123 | else if (cmp < 0) |
| 124 | n = n->leftcxx . . $ c_avl_node_s#left.; |
| 125 | else |
| 126 | n = n->rightcxx . . $ c_avl_node_s#right.; |
| 127 | } |
| 128 | |
| 129 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 130 | } |
| 131 | |
| 132 | /* (x) (y) |
| 133 | * / \ / \ |
| 134 | * (y) /\ /\ (x) |
| 135 | * / \ /_c\ ==> / a\ / \ |
| 136 | * /\ /\ /____\/\ /\ |
| 137 | * / a\ /_b\ /_b\ /_c\ |
| 138 | * /____\ |
| 139 | */ |
| 140 | static c_avl_node_tcxx . . $ c_avl_node_t# * rotate_rightcxx . . $ rotate_right(cf59c5b7759e5e1e).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, c_avl_node_tcxx . . $ c_avl_node_t# * x) |
| 141 | { |
| 142 | c_avl_node_tcxx . . $ c_avl_node_t# * p; |
| 143 | c_avl_node_tcxx . . $ c_avl_node_t# * y; |
| 144 | c_avl_node_tcxx . . $ c_avl_node_t# * b; |
| 145 | |
| 146 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(x != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 147 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(x->left != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 148 | |
| 149 | p = x->parentcxx . . $ c_avl_node_s#parent.; |
| 150 | y = x->leftcxx . . $ c_avl_node_s#left.; |
| 151 | b = y->rightcxx . . $ c_avl_node_s#right.; |
| 152 | |
| 153 | x->leftcxx . . $ c_avl_node_s#left. = b; |
| 154 | if (b != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) b->parentcxx . . $ c_avl_node_s#parent. = x; |
| 155 | |
| 156 | x->parentcxx . . $ c_avl_node_s#parent. = y; |
| 157 | y->rightcxx . . $ c_avl_node_s#right. = x; |
| 158 | |
| 159 | y->parentcxx . . $ c_avl_node_s#parent. = p; |
| 160 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (p->left == x) || (p->right == x)); |
| 161 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 162 | t->rootcxx . . $ c_avl_tree_s#root. = y; |
| 163 | else if (p->leftcxx . . $ c_avl_node_s#left. == x) |
| 164 | p->leftcxx . . $ c_avl_node_s#left. = y; |
| 165 | else |
| 166 | p->rightcxx . . $ c_avl_node_s#right. = y; |
| 167 | |
| 168 | x->heightcxx . . $ c_avl_node_s#height. = calc_heightcxx . . $ calc_height(ddf8932c150c7635).(x); |
| 169 | y->heightcxx . . $ c_avl_node_s#height. = calc_heightcxx . . $ calc_height(ddf8932c150c7635).(y); |
| 170 | |
| 171 | return y; |
| 172 | } /* void rotate_right */ |
| 173 | |
| 174 | /* |
| 175 | * (x) (y) |
| 176 | * / \ / \ |
| 177 | * /\ (y) (x) /\ |
| 178 | * /_a\ / \ ==> / \ / c\ |
| 179 | * /\ /\ /\ /\/____\ |
| 180 | * /_b\ / c\ /_a\ /_b\ |
| 181 | * /____\ |
| 182 | */ |
| 183 | static c_avl_node_tcxx . . $ c_avl_node_t# * rotate_leftcxx . . $ rotate_left(cf59c5b7759e5e1e).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, c_avl_node_tcxx . . $ c_avl_node_t# * x) |
| 184 | { |
| 185 | c_avl_node_tcxx . . $ c_avl_node_t# * p; |
| 186 | c_avl_node_tcxx . . $ c_avl_node_t# * y; |
| 187 | c_avl_node_tcxx . . $ c_avl_node_t# * b; |
| 188 | |
| 189 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(x != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 190 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(x->right != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 191 | |
| 192 | p = x->parentcxx . . $ c_avl_node_s#parent.; |
| 193 | y = x->rightcxx . . $ c_avl_node_s#right.; |
| 194 | b = y->leftcxx . . $ c_avl_node_s#left.; |
| 195 | |
| 196 | x->rightcxx . . $ c_avl_node_s#right. = b; |
| 197 | if (b != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) b->parentcxx . . $ c_avl_node_s#parent. = x; |
| 198 | |
| 199 | x->parentcxx . . $ c_avl_node_s#parent. = y; |
| 200 | y->leftcxx . . $ c_avl_node_s#left. = x; |
| 201 | |
| 202 | y->parentcxx . . $ c_avl_node_s#parent. = p; |
| 203 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (p->left == x) || (p->right == x)); |
| 204 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 205 | t->rootcxx . . $ c_avl_tree_s#root. = y; |
| 206 | else if (p->leftcxx . . $ c_avl_node_s#left. == x) |
| 207 | p->leftcxx . . $ c_avl_node_s#left. = y; |
| 208 | else |
| 209 | p->rightcxx . . $ c_avl_node_s#right. = y; |
| 210 | |
| 211 | x->heightcxx . . $ c_avl_node_s#height. = calc_heightcxx . . $ calc_height(ddf8932c150c7635).(x); |
| 212 | y->heightcxx . . $ c_avl_node_s#height. = calc_heightcxx . . $ calc_height(ddf8932c150c7635).(y); |
| 213 | |
| 214 | return y; |
| 215 | } /* void rotate_left */ |
| 216 | |
| 217 | static c_avl_node_tcxx . . $ c_avl_node_t# * rotate_left_rightcxx . . $ rotate_left_right(cf59c5b7759e5e1e).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, c_avl_node_tcxx . . $ c_avl_node_t# * x) |
| 218 | { |
| 219 | rotate_leftcxx . . $ rotate_left(cf59c5b7759e5e1e).(t, x->leftcxx . . $ c_avl_node_s#left.); |
| 220 | return rotate_rightcxx . . $ rotate_right(cf59c5b7759e5e1e).(t, x); |
| 221 | } /* void rotate_left_right */ |
| 222 | |
| 223 | static c_avl_node_tcxx . . $ c_avl_node_t# * rotate_right_leftcxx . . $ rotate_right_left(cf59c5b7759e5e1e).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, c_avl_node_tcxx . . $ c_avl_node_t# * x) |
| 224 | { |
| 225 | rotate_rightcxx . . $ rotate_right(cf59c5b7759e5e1e).(t, x->rightcxx . . $ c_avl_node_s#right.); |
| 226 | return rotate_leftcxx . . $ rotate_left(cf59c5b7759e5e1e).(t, x); |
| 227 | } /* void rotate_right_left */ |
| 228 | |
| 229 | static void rebalancecxx . . $ rebalance(45bc224c23a2088e).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, c_avl_node_tcxx . . $ c_avl_node_t# * n) |
| 230 | { |
| 231 | int b_top; |
| 232 | int b_bottom; |
| 233 | |
| 234 | while (n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 235 | { |
| 236 | b_top = BALANCEcxx . . $ `lib/libac/adt/avl_tree.c:37:9`!(n); |
| 237 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((b_top >= -2) && (b_top <= 2)); |
| 238 | |
| 239 | if (b_top == -2) |
| 240 | { |
| 241 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(n->right != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 242 | b_bottom = BALANCEcxx . . $ `lib/libac/adt/avl_tree.c:37:9`!(n->right); |
| 243 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((b_bottom >= -1) && (b_bottom <= 1)); |
| 244 | if (b_bottom == 1) |
| 245 | n = rotate_right_leftcxx . . $ rotate_right_left(cf59c5b7759e5e1e).(t, n); |
| 246 | else |
| 247 | n = rotate_leftcxx . . $ rotate_left(cf59c5b7759e5e1e).(t, n); |
| 248 | } |
| 249 | else if (b_top == 2) |
| 250 | { |
| 251 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(n->left != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 252 | b_bottom = BALANCEcxx . . $ `lib/libac/adt/avl_tree.c:37:9`!(n->left); |
| 253 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((b_bottom >= -1) && (b_bottom <= 1)); |
| 254 | if (b_bottom == -1) |
| 255 | n = rotate_left_rightcxx . . $ rotate_left_right(cf59c5b7759e5e1e).(t, n); |
| 256 | else |
| 257 | n = rotate_rightcxx . . $ rotate_right(cf59c5b7759e5e1e).(t, n); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | int height = calc_heightcxx . . $ calc_height(ddf8932c150c7635).(n); |
| 262 | if (height == n->heightcxx . . $ c_avl_node_s#height.) break; |
| 263 | n->heightcxx . . $ c_avl_node_s#height. = height; |
| 264 | } |
| 265 | |
| 266 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(n->height == calc_height(n)); |
| 267 | |
| 268 | n = n->parentcxx . . $ c_avl_node_s#parent.; |
| 269 | } /* while (n != NULL) */ |
| 270 | } /* void rebalance */ |
| 271 | |
| 272 | static c_avl_node_tcxx . . $ c_avl_node_t# * c_avl_node_nextcxx . . $ c_avl_node_next(dbe9981f92a709d9).(c_avl_node_tcxx . . $ c_avl_node_t# * n) |
| 273 | { |
| 274 | c_avl_node_tcxx . . $ c_avl_node_t# * r; /* return node */ |
| 275 | |
| 276 | if (n == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 277 | { |
| 278 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 279 | } |
| 280 | |
| 281 | /* If we can't descent any further, we have to backtrack to the first |
| 282 | * parent that's bigger than we, i. e. who's _left_ child we are. */ |
| 283 | if (n->rightcxx . . $ c_avl_node_s#right. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 284 | { |
| 285 | r = n->parentcxx . . $ c_avl_node_s#parent.; |
| 286 | while ((r != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (r->parentcxx . . $ c_avl_node_s#parent. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 287 | { |
| 288 | if (r->leftcxx . . $ c_avl_node_s#left. == n) break; |
| 289 | n = r; |
| 290 | r = n->parentcxx . . $ c_avl_node_s#parent.; |
| 291 | } |
| 292 | |
| 293 | /* n->right == NULL && r == NULL => t is root and has no next |
| 294 | * r->left != n => r->right = n => r->parent == NULL */ |
| 295 | if ((r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (r->leftcxx . . $ c_avl_node_s#left. != n)) |
| 296 | { |
| 297 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (r->parent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 298 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(r->left == n); |
| 303 | return r; |
| 304 | } |
| 305 | } |
| 306 | else |
| 307 | { |
| 308 | r = n->rightcxx . . $ c_avl_node_s#right.; |
| 309 | while (r->leftcxx . . $ c_avl_node_s#left. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) r = r->leftcxx . . $ c_avl_node_s#left.; |
| 310 | } |
| 311 | |
| 312 | return r; |
| 313 | } /* c_avl_node_t *c_avl_node_next */ |
| 314 | |
| 315 | static c_avl_node_tcxx . . $ c_avl_node_t# * c_avl_node_prevcxx . . $ c_avl_node_prev(dbe9981f92a709d9).(c_avl_node_tcxx . . $ c_avl_node_t# * n) |
| 316 | { |
| 317 | c_avl_node_tcxx . . $ c_avl_node_t# * r; /* return node */ |
| 318 | |
| 319 | if (n == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 320 | { |
| 321 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 322 | } |
| 323 | |
| 324 | /* If we can't descent any further, we have to backtrack to the first |
| 325 | * parent that's smaller than we, i. e. who's _right_ child we are. */ |
| 326 | if (n->leftcxx . . $ c_avl_node_s#left. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 327 | { |
| 328 | r = n->parentcxx . . $ c_avl_node_s#parent.; |
| 329 | while ((r != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (r->parentcxx . . $ c_avl_node_s#parent. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 330 | { |
| 331 | if (r->rightcxx . . $ c_avl_node_s#right. == n) break; |
| 332 | n = r; |
| 333 | r = n->parentcxx . . $ c_avl_node_s#parent.; |
| 334 | } |
| 335 | |
| 336 | /* n->left == NULL && r == NULL => t is root and has no next |
| 337 | * r->right != n => r->left = n => r->parent == NULL */ |
| 338 | if ((r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (r->rightcxx . . $ c_avl_node_s#right. != n)) |
| 339 | { |
| 340 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (r->parent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 341 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 342 | } |
| 343 | else |
| 344 | { |
| 345 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(r->right == n); |
| 346 | return r; |
| 347 | } |
| 348 | } |
| 349 | else |
| 350 | { |
| 351 | r = n->leftcxx . . $ c_avl_node_s#left.; |
| 352 | while (r->rightcxx . . $ c_avl_node_s#right. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) r = r->rightcxx . . $ c_avl_node_s#right.; |
| 353 | } |
| 354 | |
| 355 | return r; |
| 356 | } /* c_avl_node_t *c_avl_node_prev */ |
| 357 | |
| 358 | static int _removecxx . . $ _remove(a33bbee0def7ad38).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, c_avl_node_tcxx . . $ c_avl_node_t# * n) |
| 359 | { |
| 360 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((t != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 361 | |
| 362 | if (n && (n->leftcxx . . $ c_avl_node_s#left. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (n->rightcxx . . $ c_avl_node_s#right. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 363 | { |
| 364 | c_avl_node_tcxx . . $ c_avl_node_t# * r; /* replacement node */ |
| 365 | if (BALANCEcxx . . $ `lib/libac/adt/avl_tree.c:37:9`!(n) > 0) /* left subtree is higher */ |
| 366 | { |
| 367 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(n->left != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); //-V547 |
| 368 | r = c_avl_node_prevcxx . . $ c_avl_node_prev(dbe9981f92a709d9).(n); |
| 369 | } |
| 370 | else /* right subtree is higher */ |
| 371 | { |
| 372 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(n->right != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); //-V547 |
| 373 | r = c_avl_node_nextcxx . . $ c_avl_node_next(dbe9981f92a709d9).(n); |
| 374 | } |
| 375 | |
| 376 | ALLEGEcxx . . $ `include/aircrack-ng/defs.h:42:9`!(r != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && ((r->left == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (r->right == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))); |
| 377 | |
| 378 | /* copy content */ |
| 379 | n->keycxx . . $ c_avl_node_s#key. = r->keycxx . . $ c_avl_node_s#key.; |
| 380 | n->valuecxx . . $ c_avl_node_s#value. = r->valuecxx . . $ c_avl_node_s#value.; |
| 381 | |
| 382 | n = r; |
| 383 | } |
| 384 | |
| 385 | ALLEGEcxx . . $ `include/aircrack-ng/defs.h:42:9`!(n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && ((n->left == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (n->right == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))); |
| 386 | |
| 387 | if ((n->leftcxx . . $ c_avl_node_s#left. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (n->rightcxx . . $ c_avl_node_s#right. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 388 | { |
| 389 | /* Deleting a leave is easy */ |
| 390 | if (n->parentcxx . . $ c_avl_node_s#parent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 391 | { |
| 392 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(t->root == n); |
| 393 | t->rootcxx . . $ c_avl_tree_s#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 394 | } |
| 395 | else |
| 396 | { |
| 397 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((n->parent->left == n) || (n->parent->right == n)); |
| 398 | if (n->parentcxx . . $ c_avl_node_s#parent.->leftcxx . . $ c_avl_node_s#left. == n) |
| 399 | n->parentcxx . . $ c_avl_node_s#parent.->leftcxx . . $ c_avl_node_s#left. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 400 | else |
| 401 | n->parentcxx . . $ c_avl_node_s#parent.->rightcxx . . $ c_avl_node_s#right. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 402 | |
| 403 | rebalancecxx . . $ rebalance(45bc224c23a2088e).(t, n->parentcxx . . $ c_avl_node_s#parent.); |
| 404 | } |
| 405 | |
| 406 | free_nodecxx . . $ free_node(d1670e8f11be7e69).(n); |
| 407 | } |
| 408 | else if (n->leftcxx . . $ c_avl_node_s#left. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 409 | { |
| 410 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(BALANCEcxx . . $ `lib/libac/adt/avl_tree.c:37:9`!(n) == -1); //-V547 |
| 411 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((n->parent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (n->parent->left == n) |
| 412 | || (n->parent->right == n)); |
| 413 | if (n->parentcxx . . $ c_avl_node_s#parent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 414 | { |
| 415 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(t->root == n); |
| 416 | t->rootcxx . . $ c_avl_tree_s#root. = n->rightcxx . . $ c_avl_node_s#right.; |
| 417 | } |
| 418 | else if (n->parentcxx . . $ c_avl_node_s#parent.->leftcxx . . $ c_avl_node_s#left. == n) |
| 419 | { |
| 420 | n->parentcxx . . $ c_avl_node_s#parent.->leftcxx . . $ c_avl_node_s#left. = n->rightcxx . . $ c_avl_node_s#right.; |
| 421 | } |
| 422 | else |
| 423 | { |
| 424 | n->parentcxx . . $ c_avl_node_s#parent.->rightcxx . . $ c_avl_node_s#right. = n->rightcxx . . $ c_avl_node_s#right.; |
| 425 | } |
| 426 | ALLEGEcxx . . $ `include/aircrack-ng/defs.h:42:9`!(n->right != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 427 | n->rightcxx . . $ c_avl_node_s#right.->parentcxx . . $ c_avl_node_s#parent. = n->parentcxx . . $ c_avl_node_s#parent.; |
| 428 | |
| 429 | if (n->parentcxx . . $ c_avl_node_s#parent. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) rebalancecxx . . $ rebalance(45bc224c23a2088e).(t, n->parentcxx . . $ c_avl_node_s#parent.); |
| 430 | |
| 431 | n->rightcxx . . $ c_avl_node_s#right. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 432 | free_nodecxx . . $ free_node(d1670e8f11be7e69).(n); |
| 433 | } |
| 434 | else if (n->rightcxx . . $ c_avl_node_s#right. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 435 | { |
| 436 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(BALANCEcxx . . $ `lib/libac/adt/avl_tree.c:37:9`!(n) == 1); //-V547 |
| 437 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((n->parent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (n->parent->left == n) |
| 438 | || (n->parent->right == n)); |
| 439 | if (n->parentcxx . . $ c_avl_node_s#parent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 440 | { |
| 441 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(t->root == n); |
| 442 | t->rootcxx . . $ c_avl_tree_s#root. = n->leftcxx . . $ c_avl_node_s#left.; |
| 443 | } |
| 444 | else if (n->parentcxx . . $ c_avl_node_s#parent.->leftcxx . . $ c_avl_node_s#left. == n) |
| 445 | { |
| 446 | n->parentcxx . . $ c_avl_node_s#parent.->leftcxx . . $ c_avl_node_s#left. = n->leftcxx . . $ c_avl_node_s#left.; |
| 447 | } |
| 448 | else |
| 449 | { |
| 450 | n->parentcxx . . $ c_avl_node_s#parent.->rightcxx . . $ c_avl_node_s#right. = n->leftcxx . . $ c_avl_node_s#left.; |
| 451 | } |
| 452 | n->leftcxx . . $ c_avl_node_s#left.->parentcxx . . $ c_avl_node_s#parent. = n->parentcxx . . $ c_avl_node_s#parent.; |
| 453 | |
| 454 | if (n->parentcxx . . $ c_avl_node_s#parent. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) rebalancecxx . . $ rebalance(45bc224c23a2088e).(t, n->parentcxx . . $ c_avl_node_s#parent.); |
| 455 | |
| 456 | n->leftcxx . . $ c_avl_node_s#left. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 457 | free_nodecxx . . $ free_node(d1670e8f11be7e69).(n); |
| 458 | } |
| 459 | else |
| 460 | { |
| 461 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0); |
| 462 | } |
| 463 | |
| 464 | return 0; |
| 465 | } /* void *_remove */ |
| 466 | |
| 467 | /* |
| 468 | * public functions |
| 469 | */ |
| 470 | c_avl_tree_tcxx . . $ c_avl_tree_t# * c_avl_createcxx . . $ c_avl_create(511a77af87f6c588).(int (*compare)(const void *, const void *)) |
| 471 | { |
| 472 | c_avl_tree_tcxx . . $ c_avl_tree_t# * t; |
| 473 | |
| 474 | if (compare == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 475 | |
| 476 | if ((t = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(*t))) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 477 | |
| 478 | t->rootcxx . . $ c_avl_tree_s#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 479 | t->comparecxx . . $ c_avl_tree_s#compare. = compare; |
| 480 | t->sizecxx . . $ c_avl_tree_s#size. = 0; |
| 481 | |
| 482 | return t; |
| 483 | } |
| 484 | |
| 485 | void c_avl_destroycxx . . $ c_avl_destroy(8da9fc88abf8a84b).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t) |
| 486 | { |
| 487 | if (t == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return; |
| 488 | free_nodecxx . . $ free_node(d1670e8f11be7e69).(t->rootcxx . . $ c_avl_tree_s#root.); |
| 489 | freecxx . . $ free(5d22bdacc48458e8).(t); |
| 490 | } |
| 491 | |
| 492 | int c_avl_insertcxx . . $ c_avl_insert(9601a2e8f9790833).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, void * key, void * value) |
| 493 | { |
| 494 | c_avl_node_tcxx . . $ c_avl_node_t# * new; |
| 495 | c_avl_node_tcxx . . $ c_avl_node_t# * nptr; |
| 496 | int cmp; |
| 497 | |
| 498 | if ((new = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(*new))) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return -1; |
| 499 | |
| 500 | new->keycxx . . $ c_avl_node_s#key. = key; |
| 501 | new->valuecxx . . $ c_avl_node_s#value. = value; |
| 502 | new->heightcxx . . $ c_avl_node_s#height. = 1; |
| 503 | new->leftcxx . . $ c_avl_node_s#left. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 504 | new->rightcxx . . $ c_avl_node_s#right. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 505 | |
| 506 | if (t->rootcxx . . $ c_avl_tree_s#root. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 507 | { |
| 508 | new->parentcxx . . $ c_avl_node_s#parent. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 509 | t->rootcxx . . $ c_avl_tree_s#root. = new; |
| 510 | t->sizecxx . . $ c_avl_tree_s#size. = 1; |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | nptr = t->rootcxx . . $ c_avl_tree_s#root.; |
| 515 | while (42) |
| 516 | { |
| 517 | cmp = t->comparecxx . . $ c_avl_tree_s#compare.(nptr->keycxx . . $ c_avl_node_s#key., new->keycxx . . $ c_avl_node_s#key.); |
| 518 | if (cmp == 0) |
| 519 | { |
| 520 | free_nodecxx . . $ free_node(d1670e8f11be7e69).(new); |
| 521 | return 1; |
| 522 | } |
| 523 | else if (cmp < 0) |
| 524 | { |
| 525 | /* nptr < new */ |
| 526 | if (nptr->rightcxx . . $ c_avl_node_s#right. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 527 | { |
| 528 | nptr->rightcxx . . $ c_avl_node_s#right. = new; |
| 529 | new->parentcxx . . $ c_avl_node_s#parent. = nptr; |
| 530 | rebalancecxx . . $ rebalance(45bc224c23a2088e).(t, nptr); |
| 531 | break; |
| 532 | } |
| 533 | else |
| 534 | { |
| 535 | nptr = nptr->rightcxx . . $ c_avl_node_s#right.; |
| 536 | } |
| 537 | } |
| 538 | else /* if (cmp > 0) */ |
| 539 | { |
| 540 | /* nptr > new */ |
| 541 | if (nptr->leftcxx . . $ c_avl_node_s#left. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 542 | { |
| 543 | nptr->leftcxx . . $ c_avl_node_s#left. = new; |
| 544 | new->parentcxx . . $ c_avl_node_s#parent. = nptr; |
| 545 | rebalancecxx . . $ rebalance(45bc224c23a2088e).(t, nptr); |
| 546 | break; |
| 547 | } |
| 548 | else |
| 549 | { |
| 550 | nptr = nptr->leftcxx . . $ c_avl_node_s#left.; |
| 551 | } |
| 552 | } |
| 553 | } /* while (42) */ |
| 554 | |
| 555 | verify_treecxx . . $ `lib/libac/adt/avl_tree.c:86:9`!(t->root); |
| 556 | ++t->sizecxx . . $ c_avl_tree_s#size.; |
| 557 | return 0; |
| 558 | } /* int c_avl_insert */ |
| 559 | |
| 560 | int c_avl_removecxx . . $ c_avl_remove(e5098df54aab95cb).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, |
| 561 | const void * key, |
| 562 | void ** rkey, |
| 563 | void ** rvalue) |
| 564 | { |
| 565 | c_avl_node_tcxx . . $ c_avl_node_t# * n; |
| 566 | int status; |
| 567 | |
| 568 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(t != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 569 | |
| 570 | n = searchcxx . . $ search(accc3d88632a864d).(t, key); |
| 571 | if (n == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return -1; |
| 572 | |
| 573 | if (rkey != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) *rkey = n->keycxx . . $ c_avl_node_s#key.; |
| 574 | if (rvalue != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) *rvalue = n->valuecxx . . $ c_avl_node_s#value.; |
| 575 | |
| 576 | status = _removecxx . . $ _remove(a33bbee0def7ad38).(t, n); |
| 577 | verify_treecxx . . $ `lib/libac/adt/avl_tree.c:86:9`!(t->root); |
| 578 | --t->sizecxx . . $ c_avl_tree_s#size.; |
| 579 | return status; |
| 580 | } /* void *c_avl_remove */ |
| 581 | |
| 582 | int c_avl_getcxx . . $ c_avl_get(d64e31e3c0c0671).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, const void * key, void ** value) |
| 583 | { |
| 584 | c_avl_node_tcxx . . $ c_avl_node_t# * n; |
| 585 | |
| 586 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(t != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 587 | |
| 588 | n = searchcxx . . $ search(accc3d88632a864d).(t, key); |
| 589 | if (n == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return -1; |
| 590 | |
| 591 | if (value != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) *value = n->valuecxx . . $ c_avl_node_s#value.; |
| 592 | |
| 593 | return 0; |
| 594 | } |
| 595 | |
| 596 | int c_avl_pickcxx . . $ c_avl_pick(6e63600fc095aff6).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t, void ** key, void ** value) |
| 597 | { |
| 598 | c_avl_node_tcxx . . $ c_avl_node_t# * n; |
| 599 | c_avl_node_tcxx . . $ c_avl_node_t# * p; |
| 600 | |
| 601 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(t != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 602 | |
| 603 | if ((key == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (value == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) return -1; |
| 604 | if (t->rootcxx . . $ c_avl_tree_s#root. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return -1; |
| 605 | |
| 606 | n = t->rootcxx . . $ c_avl_tree_s#root.; |
| 607 | while ((n->leftcxx . . $ c_avl_node_s#left. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (n->rightcxx . . $ c_avl_node_s#right. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 608 | { |
| 609 | if (n->leftcxx . . $ c_avl_node_s#left. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 610 | { |
| 611 | n = n->rightcxx . . $ c_avl_node_s#right.; |
| 612 | continue; |
| 613 | } |
| 614 | else if (n->rightcxx . . $ c_avl_node_s#right. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 615 | { |
| 616 | n = n->leftcxx . . $ c_avl_node_s#left.; |
| 617 | continue; |
| 618 | } |
| 619 | |
| 620 | if (n->leftcxx . . $ c_avl_node_s#left.->heightcxx . . $ c_avl_node_s#height. > n->rightcxx . . $ c_avl_node_s#right.->heightcxx . . $ c_avl_node_s#height.) |
| 621 | n = n->leftcxx . . $ c_avl_node_s#left.; |
| 622 | else |
| 623 | n = n->rightcxx . . $ c_avl_node_s#right.; |
| 624 | } |
| 625 | |
| 626 | p = n->parentcxx . . $ c_avl_node_s#parent.; |
| 627 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 628 | t->rootcxx . . $ c_avl_tree_s#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 629 | else if (p->leftcxx . . $ c_avl_node_s#left. == n) |
| 630 | p->leftcxx . . $ c_avl_node_s#left. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 631 | else |
| 632 | p->rightcxx . . $ c_avl_node_s#right. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 633 | |
| 634 | *key = n->keycxx . . $ c_avl_node_s#key.; |
| 635 | *value = n->valuecxx . . $ c_avl_node_s#value.; |
| 636 | |
| 637 | free_nodecxx . . $ free_node(d1670e8f11be7e69).(n); |
| 638 | --t->sizecxx . . $ c_avl_tree_s#size.; |
| 639 | rebalancecxx . . $ rebalance(45bc224c23a2088e).(t, p); |
| 640 | |
| 641 | return 0; |
| 642 | } /* int c_avl_pick */ |
| 643 | |
| 644 | c_avl_iterator_tcxx . . $ c_avl_iterator_t# * c_avl_get_iteratorcxx . . $ c_avl_get_iterator(f2d8f10aaf00778f).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t) |
| 645 | { |
| 646 | c_avl_iterator_tcxx . . $ c_avl_iterator_t# * iter; |
| 647 | |
| 648 | if (t == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 649 | |
| 650 | iter = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*iter)); |
| 651 | if (iter == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 652 | iter->treecxx . . $ c_avl_iterator_s#tree. = t; |
| 653 | |
| 654 | return iter; |
| 655 | } /* c_avl_iterator_t *c_avl_get_iterator */ |
| 656 | |
| 657 | int c_avl_iterator_nextcxx . . $ c_avl_iterator_next(8db3044dd7c59e0c).(c_avl_iterator_tcxx . . $ c_avl_iterator_t# * iter, void ** key, void ** value) |
| 658 | { |
| 659 | c_avl_node_tcxx . . $ c_avl_node_t# * n; |
| 660 | |
| 661 | if ((iter == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (key == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (value == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) return -1; |
| 662 | |
| 663 | if (iter->nodecxx . . $ c_avl_iterator_s#node. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 664 | { |
| 665 | for (n = iter->treecxx . . $ c_avl_iterator_s#tree.->rootcxx . . $ c_avl_tree_s#root.; n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; n = n->leftcxx . . $ c_avl_node_s#left.) |
| 666 | if (n->leftcxx . . $ c_avl_node_s#left. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) break; |
| 667 | iter->nodecxx . . $ c_avl_iterator_s#node. = n; |
| 668 | } |
| 669 | else |
| 670 | { |
| 671 | n = c_avl_node_nextcxx . . $ c_avl_node_next(dbe9981f92a709d9).(iter->nodecxx . . $ c_avl_iterator_s#node.); |
| 672 | } |
| 673 | |
| 674 | if (n == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return -1; |
| 675 | |
| 676 | iter->nodecxx . . $ c_avl_iterator_s#node. = n; |
| 677 | *key = n->keycxx . . $ c_avl_node_s#key.; |
| 678 | *value = n->valuecxx . . $ c_avl_node_s#value.; |
| 679 | |
| 680 | return 0; |
| 681 | } /* int c_avl_iterator_next */ |
| 682 | |
| 683 | int c_avl_iterator_prevcxx . . $ c_avl_iterator_prev(8db3044dd7c59e0c).(c_avl_iterator_tcxx . . $ c_avl_iterator_t# * iter, void ** key, void ** value) |
| 684 | { |
| 685 | c_avl_node_tcxx . . $ c_avl_node_t# * n; |
| 686 | |
| 687 | if ((iter == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (key == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (value == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) return -1; |
| 688 | |
| 689 | if (iter->nodecxx . . $ c_avl_iterator_s#node. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 690 | { |
| 691 | for (n = iter->treecxx . . $ c_avl_iterator_s#tree.->rootcxx . . $ c_avl_tree_s#root.; n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; n = n->leftcxx . . $ c_avl_node_s#left.) |
| 692 | if (n->rightcxx . . $ c_avl_node_s#right. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) break; |
| 693 | iter->nodecxx . . $ c_avl_iterator_s#node. = n; |
| 694 | } |
| 695 | else |
| 696 | { |
| 697 | n = c_avl_node_prevcxx . . $ c_avl_node_prev(dbe9981f92a709d9).(iter->nodecxx . . $ c_avl_iterator_s#node.); |
| 698 | } |
| 699 | |
| 700 | if (n == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return -1; |
| 701 | |
| 702 | iter->nodecxx . . $ c_avl_iterator_s#node. = n; |
| 703 | *key = n->keycxx . . $ c_avl_node_s#key.; |
| 704 | *value = n->valuecxx . . $ c_avl_node_s#value.; |
| 705 | |
| 706 | return 0; |
| 707 | } /* int c_avl_iterator_prev */ |
| 708 | |
| 709 | void c_avl_iterator_destroycxx . . $ c_avl_iterator_destroy(6dfe2c4ad752d4d5).(c_avl_iterator_tcxx . . $ c_avl_iterator_t# * iter) { freecxx . . $ free(5d22bdacc48458e8).(iter); } |
| 710 | |
| 711 | int c_avl_sizecxx . . $ c_avl_size(801340cf1fdf6c13).(c_avl_tree_tcxx . . $ c_avl_tree_t# * t) |
| 712 | { |
| 713 | if (t == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return 0; |
| 714 | return t->sizecxx . . $ c_avl_tree_s#size.; |
| 715 | } |