| 1 | /* glpavl.c (binary search tree) */cxx . . $ `<file>/external/glpk/glpavl.c`/ |
| 2 | |
| 3 | /*********************************************************************** |
| 4 | * This code is part of GLPK (GNU Linear Programming Kit). |
| 5 | * |
| 6 | * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
| 7 | * 2009, 2010 Andrew Makhorin, Department for Applied Informatics, |
| 8 | * Moscow Aviation Institute, Moscow, Russia. All rights reserved. |
| 9 | * E-mail: <[email protected]>. |
| 10 | * |
| 11 | * GLPK is free software: you can redistribute it and/or modify it |
| 12 | * under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation, either version 3 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * GLPK is distributed in the hope that it will be useful, but WITHOUT |
| 17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 18 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 19 | * License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with GLPK. If not, see <http://www.gnu.org/licenses/>. |
| 23 | ***********************************************************************/ |
| 24 | |
| 25 | #include "glpavl.h"cxx . . $ `<file>/external/glpk/glpavl.h`/ |
| 26 | |
| 27 | AVLcxx . . $ AVL# *avl_create_treecxx . . $ `external/glpk/glpavl.h:80:9`!(int (*fcmp)(void *info, const void *key1, |
| 28 | const void *key2), void *info) |
| 29 | { /* create AVL tree */ |
| 30 | AVLcxx . . $ AVL# *tree; |
| 31 | tree = xmalloccxx . . $ `external/glpk/glpenv.h:167:9`!(sizeof(AVLcxx . . $ AVL#)); |
| 32 | tree->poolcxx . . $ AVL#pool. = dmp_create_poolcxx . . $ `external/glpk/glpdmp.h:58:9`!(); |
| 33 | tree->rootcxx . . $ AVL#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 34 | tree->fcmpcxx . . $ AVL#fcmp. = fcmp; |
| 35 | tree->infocxx . . $ AVL#info. = info; |
| 36 | tree->sizecxx . . $ AVL#size. = 0; |
| 37 | tree->heightcxx . . $ AVL#height. = 0; |
| 38 | return tree; |
| 39 | } |
| 40 | |
| 41 | int avl_strcmpcxx . . $ `external/glpk/glpavl.h:85:9`!(void *info, const void *key1, const void *key2) |
| 42 | { /* compare character string keys */ |
| 43 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(info == info); |
| 44 | return strcmpcxx . . $ strcmp(5ae29d726ae57f88).(key1, key2); |
| 45 | } |
| 46 | |
| 47 | static AVLNODEcxx . . $ AVLNODE# *rotate_subtreecxx . . $ rotate_subtree(85b248cf26853977).(AVLcxx . . $ AVL# *tree, AVLNODEcxx . . $ AVLNODE# *node); |
| 48 | |
| 49 | AVLNODEcxx . . $ AVLNODE# *avl_insert_nodecxx . . $ `external/glpk/glpavl.h:89:9`!(AVLcxx . . $ AVL# *tree, const void *key) |
| 50 | { /* insert new node into AVL tree */ |
| 51 | AVLNODEcxx . . $ AVLNODE# *p, *q, *r; |
| 52 | short int flag; |
| 53 | /* find an appropriate point for insertion */ |
| 54 | p = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; q = tree->rootcxx . . $ AVL#root.; |
| 55 | while (q != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 56 | { p = q; |
| 57 | if (tree->fcmpcxx . . $ AVL#fcmp.(tree->infocxx . . $ AVL#info., key, p->keycxx . . $ AVLNODE#key.) <= 0) |
| 58 | { flag = 0; |
| 59 | q = p->leftcxx . . $ AVLNODE#left.; |
| 60 | p->rankcxx . . $ AVLNODE#rank.++; |
| 61 | } |
| 62 | else |
| 63 | { flag = 1; |
| 64 | q = p->rightcxx . . $ AVLNODE#right.; |
| 65 | } |
| 66 | } |
| 67 | /* create new node and insert it into the tree */ |
| 68 | r = dmp_get_atomcxx . . $ `external/glpk/glpdmp.h:62:9`!(tree->poolcxx . . $ AVL#pool., sizeof(AVLNODEcxx . . $ AVLNODE#)); |
| 69 | r->keycxx . . $ AVLNODE#key. = key; r->typecxx . . $ AVLNODE#type. = 0; r->linkcxx . . $ AVLNODE#link. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 70 | r->rankcxx . . $ AVLNODE#rank. = 1; r->upcxx . . $ AVLNODE#up. = p; |
| 71 | r->flagcxx . . $ AVLNODE#flag. = (short int)(p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? 0 : flag); |
| 72 | r->balcxx . . $ AVLNODE#bal. = 0; r->leftcxx . . $ AVLNODE#left. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; r->rightcxx . . $ AVLNODE#right. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 73 | tree->sizecxx . . $ AVL#size.++; |
| 74 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 75 | tree->rootcxx . . $ AVL#root. = r; |
| 76 | else |
| 77 | if (flag == 0) p->leftcxx . . $ AVLNODE#left. = r; else p->rightcxx . . $ AVLNODE#right. = r; |
| 78 | /* go upstairs to the root and correct all subtrees affected by |
| 79 | insertion */ |
| 80 | while (p != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 81 | { if (flag == 0) |
| 82 | { /* the height of the left subtree of [p] is increased */ |
| 83 | if (p->balcxx . . $ AVLNODE#bal. > 0) |
| 84 | { p->balcxx . . $ AVLNODE#bal. = 0; |
| 85 | break; |
| 86 | } |
| 87 | if (p->balcxx . . $ AVLNODE#bal. < 0) |
| 88 | { rotate_subtreecxx . . $ rotate_subtree(85b248cf26853977).(tree, p); |
| 89 | break; |
| 90 | } |
| 91 | p->balcxx . . $ AVLNODE#bal. = -1; flag = p->flagcxx . . $ AVLNODE#flag.; p = p->upcxx . . $ AVLNODE#up.; |
| 92 | } |
| 93 | else |
| 94 | { /* the height of the right subtree of [p] is increased */ |
| 95 | if (p->balcxx . . $ AVLNODE#bal. < 0) |
| 96 | { p->balcxx . . $ AVLNODE#bal. = 0; |
| 97 | break; |
| 98 | } |
| 99 | if (p->balcxx . . $ AVLNODE#bal. > 0) |
| 100 | { rotate_subtreecxx . . $ rotate_subtree(85b248cf26853977).(tree, p); |
| 101 | break; |
| 102 | } |
| 103 | p->balcxx . . $ AVLNODE#bal. = +1; flag = p->flagcxx . . $ AVLNODE#flag.; p = p->upcxx . . $ AVLNODE#up.; |
| 104 | } |
| 105 | } |
| 106 | /* if the root has been reached, the height of the entire tree is |
| 107 | increased */ |
| 108 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) tree->heightcxx . . $ AVL#height.++; |
| 109 | return r; |
| 110 | } |
| 111 | |
| 112 | void avl_set_node_typecxx . . $ `external/glpk/glpavl.h:93:9`!(AVLNODEcxx . . $ AVLNODE# *node, int type) |
| 113 | { /* assign the type field of specified node */ |
| 114 | node->typecxx . . $ AVLNODE#type. = type; |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | void avl_set_node_linkcxx . . $ `external/glpk/glpavl.h:97:9`!(AVLNODEcxx . . $ AVLNODE# *node, void *link) |
| 119 | { /* assign the link field of specified node */ |
| 120 | node->linkcxx . . $ AVLNODE#link. = link; |
| 121 | return; |
| 122 | } |
| 123 | |
| 124 | AVLNODEcxx . . $ AVLNODE# *avl_find_nodecxx . . $ `external/glpk/glpavl.h:101:9`!(AVLcxx . . $ AVL# *tree, const void *key) |
| 125 | { /* find node in AVL tree */ |
| 126 | AVLNODEcxx . . $ AVLNODE# *p; |
| 127 | int c; |
| 128 | p = tree->rootcxx . . $ AVL#root.; |
| 129 | while (p != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 130 | { c = tree->fcmpcxx . . $ AVL#fcmp.(tree->infocxx . . $ AVL#info., key, p->keycxx . . $ AVLNODE#key.); |
| 131 | if (c == 0) break; |
| 132 | p = (c < 0 ? p->leftcxx . . $ AVLNODE#left. : p->rightcxx . . $ AVLNODE#right.); |
| 133 | } |
| 134 | return p; |
| 135 | } |
| 136 | |
| 137 | int avl_get_node_typecxx . . $ `external/glpk/glpavl.h:105:9`!(AVLNODEcxx . . $ AVLNODE# *node) |
| 138 | { /* retrieve the type field of specified node */ |
| 139 | return node->typecxx . . $ AVLNODE#type.; |
| 140 | } |
| 141 | |
| 142 | void *avl_get_node_linkcxx . . $ `external/glpk/glpavl.h:109:9`!(AVLNODEcxx . . $ AVLNODE# *node) |
| 143 | { /* retrieve the link field of specified node */ |
| 144 | return node->linkcxx . . $ AVLNODE#link.; |
| 145 | } |
| 146 | |
| 147 | static AVLNODEcxx . . $ AVLNODE# *find_next_nodecxx . . $ find_next_node(85b248cf26853977).(AVLcxx . . $ AVL# *tree, AVLNODEcxx . . $ AVLNODE# *node) |
| 148 | { /* find next node in AVL tree */ |
| 149 | AVLNODEcxx . . $ AVLNODE# *p, *q; |
| 150 | if (tree->rootcxx . . $ AVL#root. == 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`!; |
| 151 | p = node; |
| 152 | q = (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? tree->rootcxx . . $ AVL#root. : p->rightcxx . . $ AVLNODE#right.); |
| 153 | if (q == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 154 | { /* go upstairs from the left subtree */ |
| 155 | for (;;) |
| 156 | { q = p->upcxx . . $ AVLNODE#up.; |
| 157 | if (q == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) break; |
| 158 | if (p->flagcxx . . $ AVLNODE#flag. == 0) break; |
| 159 | p = q; |
| 160 | } |
| 161 | } |
| 162 | else |
| 163 | { /* go downstairs into the right subtree */ |
| 164 | for (;;) |
| 165 | { p = q->leftcxx . . $ AVLNODE#left.; |
| 166 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) break; |
| 167 | q = p; |
| 168 | } |
| 169 | } |
| 170 | return q; |
| 171 | } |
| 172 | |
| 173 | void avl_delete_nodecxx . . $ `external/glpk/glpavl.h:113:9`!(AVLcxx . . $ AVL# *tree, AVLNODEcxx . . $ AVLNODE# *node) |
| 174 | { /* delete specified node from AVL tree */ |
| 175 | AVLNODEcxx . . $ AVLNODE# *f, *p, *q, *r, *s, *x, *y; |
| 176 | short int flag; |
| 177 | p = node; |
| 178 | /* if both subtrees of the specified node are non-empty, the node |
| 179 | should be interchanged with the next one, at least one subtree |
| 180 | of which is always empty */ |
| 181 | if (p->leftcxx . . $ AVLNODE#left. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || p->rightcxx . . $ AVLNODE#right. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) goto skip; |
| 182 | f = p->upcxx . . $ AVLNODE#up.; q = p->leftcxx . . $ AVLNODE#left.; |
| 183 | r = find_next_nodecxx . . $ find_next_node(85b248cf26853977).(tree, p); s = r->rightcxx . . $ AVLNODE#right.; |
| 184 | if (p->rightcxx . . $ AVLNODE#right. == r) |
| 185 | { if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 186 | tree->rootcxx . . $ AVL#root. = r; |
| 187 | else |
| 188 | if (p->flagcxx . . $ AVLNODE#flag. == 0) f->leftcxx . . $ AVLNODE#left. = r; else f->rightcxx . . $ AVLNODE#right. = r; |
| 189 | r->rankcxx . . $ AVLNODE#rank. = p->rankcxx . . $ AVLNODE#rank.; r->upcxx . . $ AVLNODE#up. = f; |
| 190 | r->flagcxx . . $ AVLNODE#flag. = p->flagcxx . . $ AVLNODE#flag.; r->balcxx . . $ AVLNODE#bal. = p->balcxx . . $ AVLNODE#bal.; |
| 191 | r->leftcxx . . $ AVLNODE#left. = q; r->rightcxx . . $ AVLNODE#right. = p; |
| 192 | q->upcxx . . $ AVLNODE#up. = r; |
| 193 | p->rankcxx . . $ AVLNODE#rank. = 1; p->upcxx . . $ AVLNODE#up. = r; p->flagcxx . . $ AVLNODE#flag. = 1; |
| 194 | p->balcxx . . $ AVLNODE#bal. = (short int)(s == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? 0 : +1); |
| 195 | p->leftcxx . . $ AVLNODE#left. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; p->rightcxx . . $ AVLNODE#right. = s; |
| 196 | if (s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) s->upcxx . . $ AVLNODE#up. = p; |
| 197 | } |
| 198 | else |
| 199 | { x = p->rightcxx . . $ AVLNODE#right.; y = r->upcxx . . $ AVLNODE#up.; |
| 200 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 201 | tree->rootcxx . . $ AVL#root. = r; |
| 202 | else |
| 203 | if (p->flagcxx . . $ AVLNODE#flag. == 0) f->leftcxx . . $ AVLNODE#left. = r; else f->rightcxx . . $ AVLNODE#right. = r; |
| 204 | r->rankcxx . . $ AVLNODE#rank. = p->rankcxx . . $ AVLNODE#rank.; r->upcxx . . $ AVLNODE#up. = f; |
| 205 | r->flagcxx . . $ AVLNODE#flag. = p->flagcxx . . $ AVLNODE#flag.; r->balcxx . . $ AVLNODE#bal. = p->balcxx . . $ AVLNODE#bal.; |
| 206 | r->leftcxx . . $ AVLNODE#left. = q; r->rightcxx . . $ AVLNODE#right. = x; |
| 207 | q->upcxx . . $ AVLNODE#up. = r; x->upcxx . . $ AVLNODE#up. = r; y->leftcxx . . $ AVLNODE#left. = p; |
| 208 | p->rankcxx . . $ AVLNODE#rank. = 1; p->upcxx . . $ AVLNODE#up. = y; p->flagcxx . . $ AVLNODE#flag. = 0; |
| 209 | p->balcxx . . $ AVLNODE#bal. = (short int)(s == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? 0 : +1); |
| 210 | p->leftcxx . . $ AVLNODE#left. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; p->rightcxx . . $ AVLNODE#right. = s; |
| 211 | if (s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) s->upcxx . . $ AVLNODE#up. = p; |
| 212 | } |
| 213 | skip: /* now the specified node [p] has at least one empty subtree; |
| 214 | go upstairs to the root and adjust the rank field of all nodes |
| 215 | affected by deletion */ |
| 216 | q = p; f = q->upcxx . . $ AVLNODE#up.; |
| 217 | while (f != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 218 | { if (q->flagcxx . . $ AVLNODE#flag. == 0) f->rankcxx . . $ AVLNODE#rank.--; |
| 219 | q = f; f = q->upcxx . . $ AVLNODE#up.; |
| 220 | } |
| 221 | /* delete the specified node from the tree */ |
| 222 | f = p->upcxx . . $ AVLNODE#up.; flag = p->flagcxx . . $ AVLNODE#flag.; |
| 223 | q = p->leftcxx . . $ AVLNODE#left. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? p->leftcxx . . $ AVLNODE#left. : p->rightcxx . . $ AVLNODE#right.; |
| 224 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 225 | tree->rootcxx . . $ AVL#root. = q; |
| 226 | else |
| 227 | if (flag == 0) f->leftcxx . . $ AVLNODE#left. = q; else f->rightcxx . . $ AVLNODE#right. = q; |
| 228 | if (q != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) q->upcxx . . $ AVLNODE#up. = f, q->flagcxx . . $ AVLNODE#flag. = flag; |
| 229 | tree->sizecxx . . $ AVL#size.--; |
| 230 | /* go upstairs to the root and correct all subtrees affected by |
| 231 | deletion */ |
| 232 | while (f != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 233 | { if (flag == 0) |
| 234 | { /* the height of the left subtree of [f] is decreased */ |
| 235 | if (f->balcxx . . $ AVLNODE#bal. == 0) |
| 236 | { f->balcxx . . $ AVLNODE#bal. = +1; |
| 237 | break; |
| 238 | } |
| 239 | if (f->balcxx . . $ AVLNODE#bal. < 0) |
| 240 | f->balcxx . . $ AVLNODE#bal. = 0; |
| 241 | else |
| 242 | { f = rotate_subtreecxx . . $ rotate_subtree(85b248cf26853977).(tree, f); |
| 243 | if (f->balcxx . . $ AVLNODE#bal. < 0) break; |
| 244 | } |
| 245 | flag = f->flagcxx . . $ AVLNODE#flag.; f = f->upcxx . . $ AVLNODE#up.; |
| 246 | } |
| 247 | else |
| 248 | { /* the height of the right subtree of [f] is decreased */ |
| 249 | if (f->balcxx . . $ AVLNODE#bal. == 0) |
| 250 | { f->balcxx . . $ AVLNODE#bal. = -1; |
| 251 | break; |
| 252 | } |
| 253 | if (f->balcxx . . $ AVLNODE#bal. > 0) |
| 254 | f->balcxx . . $ AVLNODE#bal. = 0; |
| 255 | else |
| 256 | { f = rotate_subtreecxx . . $ rotate_subtree(85b248cf26853977).(tree, f); |
| 257 | if (f->balcxx . . $ AVLNODE#bal. > 0) break; |
| 258 | } |
| 259 | flag = f->flagcxx . . $ AVLNODE#flag.; f = f->upcxx . . $ AVLNODE#up.; |
| 260 | } |
| 261 | } |
| 262 | /* if the root has been reached, the height of the entire tree is |
| 263 | decreased */ |
| 264 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) tree->heightcxx . . $ AVL#height.--; |
| 265 | /* returns the deleted node to the memory pool */ |
| 266 | dmp_free_atomcxx . . $ `external/glpk/glpdmp.h:66:9`!(tree->poolcxx . . $ AVL#pool., p, sizeof(AVLNODEcxx . . $ AVLNODE#)); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | static AVLNODEcxx . . $ AVLNODE# *rotate_subtreecxx . . $ rotate_subtree(85b248cf26853977).(AVLcxx . . $ AVL# *tree, AVLNODEcxx . . $ AVLNODE# *node) |
| 271 | { /* restore balance of AVL subtree */ |
| 272 | AVLNODEcxx . . $ AVLNODE# *f, *p, *q, *r, *x, *y; |
| 273 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(node != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 274 | p = node; |
| 275 | if (p->balcxx . . $ AVLNODE#bal. < 0) |
| 276 | { /* perform negative (left) rotation */ |
| 277 | f = p->upcxx . . $ AVLNODE#up.; q = p->leftcxx . . $ AVLNODE#left.; r = q->rightcxx . . $ AVLNODE#right.; |
| 278 | if (q->balcxx . . $ AVLNODE#bal. <= 0) |
| 279 | { /* perform single negative rotation */ |
| 280 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 281 | tree->rootcxx . . $ AVL#root. = q; |
| 282 | else |
| 283 | if (p->flagcxx . . $ AVLNODE#flag. == 0) f->leftcxx . . $ AVLNODE#left. = q; else f->rightcxx . . $ AVLNODE#right. = q; |
| 284 | p->rankcxx . . $ AVLNODE#rank. -= q->rankcxx . . $ AVLNODE#rank.; |
| 285 | q->upcxx . . $ AVLNODE#up. = f; q->flagcxx . . $ AVLNODE#flag. = p->flagcxx . . $ AVLNODE#flag.; q->balcxx . . $ AVLNODE#bal.++; q->rightcxx . . $ AVLNODE#right. = p; |
| 286 | p->upcxx . . $ AVLNODE#up. = q; p->flagcxx . . $ AVLNODE#flag. = 1; |
| 287 | p->balcxx . . $ AVLNODE#bal. = (short int)(-q->balcxx . . $ AVLNODE#bal.); p->leftcxx . . $ AVLNODE#left. = r; |
| 288 | if (r != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) r->upcxx . . $ AVLNODE#up. = p, r->flagcxx . . $ AVLNODE#flag. = 0; |
| 289 | node = q; |
| 290 | } |
| 291 | else |
| 292 | { /* perform double negative rotation */ |
| 293 | x = r->leftcxx . . $ AVLNODE#left.; y = r->rightcxx . . $ AVLNODE#right.; |
| 294 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 295 | tree->rootcxx . . $ AVL#root. = r; |
| 296 | else |
| 297 | if (p->flagcxx . . $ AVLNODE#flag. == 0) f->leftcxx . . $ AVLNODE#left. = r; else f->rightcxx . . $ AVLNODE#right. = r; |
| 298 | p->rankcxx . . $ AVLNODE#rank. -= (q->rankcxx . . $ AVLNODE#rank. + r->rankcxx . . $ AVLNODE#rank.); |
| 299 | r->rankcxx . . $ AVLNODE#rank. += q->rankcxx . . $ AVLNODE#rank.; |
| 300 | p->balcxx . . $ AVLNODE#bal. = (short int)(r->balcxx . . $ AVLNODE#bal. >= 0 ? 0 : +1); |
| 301 | q->balcxx . . $ AVLNODE#bal. = (short int)(r->balcxx . . $ AVLNODE#bal. <= 0 ? 0 : -1); |
| 302 | r->upcxx . . $ AVLNODE#up. = f; r->flagcxx . . $ AVLNODE#flag. = p->flagcxx . . $ AVLNODE#flag.; r->balcxx . . $ AVLNODE#bal. = 0; |
| 303 | r->leftcxx . . $ AVLNODE#left. = q; r->rightcxx . . $ AVLNODE#right. = p; |
| 304 | p->upcxx . . $ AVLNODE#up. = r; p->flagcxx . . $ AVLNODE#flag. = 1; p->leftcxx . . $ AVLNODE#left. = y; |
| 305 | q->upcxx . . $ AVLNODE#up. = r; q->flagcxx . . $ AVLNODE#flag. = 0; q->rightcxx . . $ AVLNODE#right. = x; |
| 306 | if (x != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) x->upcxx . . $ AVLNODE#up. = q, x->flagcxx . . $ AVLNODE#flag. = 1; |
| 307 | if (y != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) y->upcxx . . $ AVLNODE#up. = p, y->flagcxx . . $ AVLNODE#flag. = 0; |
| 308 | node = r; |
| 309 | } |
| 310 | } |
| 311 | else |
| 312 | { /* perform positive (right) rotation */ |
| 313 | f = p->upcxx . . $ AVLNODE#up.; q = p->rightcxx . . $ AVLNODE#right.; r = q->leftcxx . . $ AVLNODE#left.; |
| 314 | if (q->balcxx . . $ AVLNODE#bal. >= 0) |
| 315 | { /* perform single positive rotation */ |
| 316 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 317 | tree->rootcxx . . $ AVL#root. = q; |
| 318 | else |
| 319 | if (p->flagcxx . . $ AVLNODE#flag. == 0) f->leftcxx . . $ AVLNODE#left. = q; else f->rightcxx . . $ AVLNODE#right. = q; |
| 320 | q->rankcxx . . $ AVLNODE#rank. += p->rankcxx . . $ AVLNODE#rank.; |
| 321 | q->upcxx . . $ AVLNODE#up. = f; q->flagcxx . . $ AVLNODE#flag. = p->flagcxx . . $ AVLNODE#flag.; q->balcxx . . $ AVLNODE#bal.--; q->leftcxx . . $ AVLNODE#left. = p; |
| 322 | p->upcxx . . $ AVLNODE#up. = q; p->flagcxx . . $ AVLNODE#flag. = 0; |
| 323 | p->balcxx . . $ AVLNODE#bal. = (short int)(-q->balcxx . . $ AVLNODE#bal.); p->rightcxx . . $ AVLNODE#right. = r; |
| 324 | if (r != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) r->upcxx . . $ AVLNODE#up. = p, r->flagcxx . . $ AVLNODE#flag. = 1; |
| 325 | node = q; |
| 326 | } |
| 327 | else |
| 328 | { /* perform double positive rotation */ |
| 329 | x = r->leftcxx . . $ AVLNODE#left.; y = r->rightcxx . . $ AVLNODE#right.; |
| 330 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 331 | tree->rootcxx . . $ AVL#root. = r; |
| 332 | else |
| 333 | if (p->flagcxx . . $ AVLNODE#flag. == 0) f->leftcxx . . $ AVLNODE#left. = r; else f->rightcxx . . $ AVLNODE#right. = r; |
| 334 | q->rankcxx . . $ AVLNODE#rank. -= r->rankcxx . . $ AVLNODE#rank.; |
| 335 | r->rankcxx . . $ AVLNODE#rank. += p->rankcxx . . $ AVLNODE#rank.; |
| 336 | p->balcxx . . $ AVLNODE#bal. = (short int)(r->balcxx . . $ AVLNODE#bal. <= 0 ? 0 : -1); |
| 337 | q->balcxx . . $ AVLNODE#bal. = (short int)(r->balcxx . . $ AVLNODE#bal. >= 0 ? 0 : +1); |
| 338 | r->upcxx . . $ AVLNODE#up. = f; r->flagcxx . . $ AVLNODE#flag. = p->flagcxx . . $ AVLNODE#flag.; r->balcxx . . $ AVLNODE#bal. = 0; |
| 339 | r->leftcxx . . $ AVLNODE#left. = p; r->rightcxx . . $ AVLNODE#right. = q; |
| 340 | p->upcxx . . $ AVLNODE#up. = r; p->flagcxx . . $ AVLNODE#flag. = 0; p->rightcxx . . $ AVLNODE#right. = x; |
| 341 | q->upcxx . . $ AVLNODE#up. = r; q->flagcxx . . $ AVLNODE#flag. = 1; q->leftcxx . . $ AVLNODE#left. = y; |
| 342 | if (x != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) x->upcxx . . $ AVLNODE#up. = p, x->flagcxx . . $ AVLNODE#flag. = 1; |
| 343 | if (y != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) y->upcxx . . $ AVLNODE#up. = q, y->flagcxx . . $ AVLNODE#flag. = 0; |
| 344 | node = r; |
| 345 | } |
| 346 | } |
| 347 | return node; |
| 348 | } |
| 349 | |
| 350 | void avl_delete_treecxx . . $ `external/glpk/glpavl.h:117:9`!(AVLcxx . . $ AVL# *tree) |
| 351 | { /* delete AVL tree */ |
| 352 | dmp_delete_poolcxx . . $ `external/glpk/glpdmp.h:74:9`!(tree->poolcxx . . $ AVL#pool.); |
| 353 | xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tree); |
| 354 | return; |
| 355 | } |
| 356 | |
| 357 | /* eof */ |