| 1 | /* glpavl.h (binary search tree) */cxx . . $ `<file>/external/glpk/glpavl.h`/ |
| 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 | #ifndef GLPAVL_H |
| 26 | #define GLPAVL_Hcxx . . $ `external/glpk/glpavl.h:26:9`! |
| 27 | |
| 28 | #include "glpdmp.h"cxx . . $ `<file>/external/glpk/glpdmp.h`/ |
| 29 | |
| 30 | typedef struct AVLcxx . . $ AVL# AVLcxx . . $ AVL#; |
| 31 | typedef struct AVLNODEcxx . . $ AVLNODE# AVLNODEcxx . . $ AVLNODE#; |
| 32 | |
| 33 | struct AVLcxx . . $ AVL# |
| 34 | { /* AVL tree (Adelson-Velsky & Landis binary search tree) */ |
| 35 | DMPcxx . . $ DMP# *poolcxx . . $ AVL#pool.; |
| 36 | /* memory pool for allocating nodes */ |
| 37 | AVLNODEcxx . . $ AVLNODE# *rootcxx . . $ AVL#root.; |
| 38 | /* pointer to the root node */ |
| 39 | int (*fcmpcxx . . $ AVL#fcmp.)(void *info, const void *key1, const void *key2); |
| 40 | /* application-defined key comparison routine */ |
| 41 | void *infocxx . . $ AVL#info.; |
| 42 | /* transit pointer passed to the routine fcmp */ |
| 43 | int sizecxx . . $ AVL#size.; |
| 44 | /* the tree size (the total number of nodes) */ |
| 45 | int heightcxx . . $ AVL#height.; |
| 46 | /* the tree height */ |
| 47 | }; |
| 48 | |
| 49 | struct AVLNODEcxx . . $ AVLNODE# |
| 50 | { /* node of AVL tree */ |
| 51 | const void *keycxx . . $ AVLNODE#key.; |
| 52 | /* pointer to the node key (data structure for representing keys |
| 53 | is supplied by the application) */ |
| 54 | int rankcxx . . $ AVLNODE#rank.; |
| 55 | /* node rank = relative position of the node in its own subtree = |
| 56 | the number of nodes in the left subtree plus one */ |
| 57 | int typecxx . . $ AVLNODE#type.; |
| 58 | /* reserved for the application specific information */ |
| 59 | void *linkcxx . . $ AVLNODE#link.; |
| 60 | /* reserved for the application specific information */ |
| 61 | AVLNODEcxx . . $ AVLNODE# *upcxx . . $ AVLNODE#up.; |
| 62 | /* pointer to the parent node */ |
| 63 | short int flagcxx . . $ AVLNODE#flag.; |
| 64 | /* node flag: |
| 65 | 0 - this node is the left child of its parent (or this node is |
| 66 | the root of the tree and has no parent) |
| 67 | 1 - this node is the right child of its parent */ |
| 68 | short int balcxx . . $ AVLNODE#bal.; |
| 69 | /* node balance = the difference between heights of the right and |
| 70 | left subtrees: |
| 71 | -1 - the left subtree is higher than the right one; |
| 72 | 0 - the left and right subtrees have the same height; |
| 73 | +1 - the left subtree is lower than the right one */ |
| 74 | AVLNODEcxx . . $ AVLNODE# *leftcxx . . $ AVLNODE#left.; |
| 75 | /* pointer to the root of the left subtree */ |
| 76 | AVLNODEcxx . . $ AVLNODE# *rightcxx . . $ AVLNODE#right.; |
| 77 | /* pointer to the root of the right subtree */ |
| 78 | }; |
| 79 | |
| 80 | #define avl_create_treecxx . . $ `external/glpk/glpavl.h:80:9`! _glp_avl_create_tree |
| 81 | AVLcxx . . $ AVL# *avl_create_treecxx . . $ `external/glpk/glpavl.h:80:9`!(int (*fcmp)(void *info, const void *key1, |
| 82 | const void *key2), void *info); |
| 83 | /* create AVL tree */ |
| 84 | |
| 85 | #define avl_strcmpcxx . . $ `external/glpk/glpavl.h:85:9`! _glp_avl_strcmp |
| 86 | int avl_strcmpcxx . . $ `external/glpk/glpavl.h:85:9`!(void *info, const void *key1, const void *key2); |
| 87 | /* compare character string keys */ |
| 88 | |
| 89 | #define avl_insert_nodecxx . . $ `external/glpk/glpavl.h:89:9`! _glp_avl_insert_node |
| 90 | AVLNODEcxx . . $ AVLNODE# *avl_insert_nodecxx . . $ `external/glpk/glpavl.h:89:9`!(AVLcxx . . $ AVL# *tree, const void *key); |
| 91 | /* insert new node into AVL tree */ |
| 92 | |
| 93 | #define avl_set_node_typecxx . . $ `external/glpk/glpavl.h:93:9`! _glp_avl_set_node_type |
| 94 | void avl_set_node_typecxx . . $ `external/glpk/glpavl.h:93:9`!(AVLNODEcxx . . $ AVLNODE# *node, int type); |
| 95 | /* assign the type field of specified node */ |
| 96 | |
| 97 | #define avl_set_node_linkcxx . . $ `external/glpk/glpavl.h:97:9`! _glp_avl_set_node_link |
| 98 | void avl_set_node_linkcxx . . $ `external/glpk/glpavl.h:97:9`!(AVLNODEcxx . . $ AVLNODE# *node, void *link); |
| 99 | /* assign the link field of specified node */ |
| 100 | |
| 101 | #define avl_find_nodecxx . . $ `external/glpk/glpavl.h:101:9`! _glp_avl_find_node |
| 102 | AVLNODEcxx . . $ AVLNODE# *avl_find_nodecxx . . $ `external/glpk/glpavl.h:101:9`!(AVLcxx . . $ AVL# *tree, const void *key); |
| 103 | /* find node in AVL tree */ |
| 104 | |
| 105 | #define avl_get_node_typecxx . . $ `external/glpk/glpavl.h:105:9`! _glp_avl_get_node_type |
| 106 | int avl_get_node_typecxx . . $ `external/glpk/glpavl.h:105:9`!(AVLNODEcxx . . $ AVLNODE# *node); |
| 107 | /* retrieve the type field of specified node */ |
| 108 | |
| 109 | #define avl_get_node_linkcxx . . $ `external/glpk/glpavl.h:109:9`! _glp_avl_get_node_link |
| 110 | void *avl_get_node_linkcxx . . $ `external/glpk/glpavl.h:109:9`!(AVLNODEcxx . . $ AVLNODE# *node); |
| 111 | /* retrieve the link field of specified node */ |
| 112 | |
| 113 | #define avl_delete_nodecxx . . $ `external/glpk/glpavl.h:113:9`! _glp_avl_delete_node |
| 114 | void avl_delete_nodecxx . . $ `external/glpk/glpavl.h:113:9`!(AVLcxx . . $ AVL# *tree, AVLNODEcxx . . $ AVLNODE# *node); |
| 115 | /* delete specified node from AVL tree */ |
| 116 | |
| 117 | #define avl_delete_treecxx . . $ `external/glpk/glpavl.h:117:9`! _glp_avl_delete_tree |
| 118 | void avl_delete_treecxx . . $ `external/glpk/glpavl.h:117:9`!(AVLcxx . . $ AVL# *tree); |
| 119 | /* delete AVL tree */ |
| 120 | |
| 121 | #endif |
| 122 | |
| 123 | /* eof */ |