Main Page | Modules | File List | Globals

_gdsl_bintree.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the Generic Data Structures Library (GDSL).
00003  * Copyright (C) 1998-2004 Nicolas Darnis <ndarnis@free.fr>.
00004  *
00005  * The GDSL library is free software; you can redistribute it and/or 
00006  * modify it under the terms of the GNU General Public License as 
00007  * published by the Free Software Foundation; either version 2 of
00008  * the License, or (at your option) any later version.
00009  *
00010  * The GDSL library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with the GDSL library; see the file COPYING.
00017  * If not, write to the Free Software Foundation, Inc., 
00018  * 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  * $RCSfile: __gdsl__bintree_8h-source.html,v $
00021  * $Revision: 1.4 $
00022  * $Date: 2004/10/03 14:35:37 $
00023  */
00024 
00025 #ifndef __GDSL_BINTREE_H_
00026 #define __GDSL_BINTREE_H_
00027 
00028 
00029 #include <stdio.h>
00030 
00031 
00032 #include "gdsl_types.h"
00033 #include "gdsl_macros.h"
00034 
00035 
00036 #if __cplusplus
00037 extern "C" 
00038 {
00039 #endif /* __cplusplus */
00040 
00041 
00053 typedef struct _gdsl_bintree* _gdsl_bintree_t;
00054 
00061 typedef int (* gdsl_bintree_map_func_t) (_gdsl_bintree_t TREE,
00062                      void *USER_DATA
00063                      );
00064 
00065 /******************************************************************************/
00066 /* Management functions of low-level binary trees                             */
00067 /******************************************************************************/
00068 
00084 extern _gdsl_bintree_t
00085 _gdsl_bintree_alloc (const gdsl_element_t E,
00086              const _gdsl_bintree_t LEFT,
00087              const _gdsl_bintree_t RIGHT
00088              );
00089 
00103 extern void 
00104 _gdsl_bintree_free (_gdsl_bintree_t T,
00105             const gdsl_free_func_t FREE_F
00106             );
00107 
00125 extern _gdsl_bintree_t
00126 _gdsl_bintree_copy (const _gdsl_bintree_t T,
00127             const gdsl_copy_func_t COPY_F
00128             );
00129 
00130 /******************************************************************************/
00131 /* Consultation functions of low-level binary trees                           */
00132 /******************************************************************************/
00133 
00144 extern bool
00145 _gdsl_bintree_is_empty (const _gdsl_bintree_t T
00146             );
00147   
00158 extern bool
00159 _gdsl_bintree_is_leaf (const _gdsl_bintree_t T
00160                );
00161 
00172 extern bool
00173 _gdsl_bintree_is_root (const _gdsl_bintree_t T
00174                );
00175 
00184 extern gdsl_element_t
00185 _gdsl_bintree_get_content (const _gdsl_bintree_t T
00186                );
00187 
00198 extern _gdsl_bintree_t
00199 _gdsl_bintree_get_parent (const _gdsl_bintree_t T
00200               );
00201 
00217 extern _gdsl_bintree_t
00218 _gdsl_bintree_get_left (const _gdsl_bintree_t T
00219             );
00220 
00236 extern _gdsl_bintree_t
00237 _gdsl_bintree_get_right (const _gdsl_bintree_t T
00238              );
00239 
00248 extern _gdsl_bintree_t*
00249 _gdsl_bintree_get_left_ref (const _gdsl_bintree_t T
00250                 );
00251 
00260 extern _gdsl_bintree_t*
00261 _gdsl_bintree_get_right_ref (const _gdsl_bintree_t T
00262                  );
00263 
00275 extern ulong
00276 _gdsl_bintree_get_height (const _gdsl_bintree_t T
00277               );
00278 
00287 extern ulong
00288 _gdsl_bintree_get_size (const _gdsl_bintree_t T
00289             );
00290 
00291 /******************************************************************************/
00292 /* Modification functions of low-level binary trees                           */
00293 /******************************************************************************/
00294 
00306 extern void
00307 _gdsl_bintree_set_content (_gdsl_bintree_t T,
00308                const gdsl_element_t E
00309                );
00310 
00322 extern void
00323 _gdsl_bintree_set_parent (_gdsl_bintree_t T,
00324               const _gdsl_bintree_t P
00325               );
00326 
00340 extern void
00341 _gdsl_bintree_set_left (_gdsl_bintree_t T,
00342             const _gdsl_bintree_t L
00343             );
00344   
00358 extern void
00359 _gdsl_bintree_set_right (_gdsl_bintree_t T,
00360              const _gdsl_bintree_t R
00361              );
00362 
00363 /******************************************************************************/
00364 /* Rotation functions of low-level binary trees                               */
00365 /******************************************************************************/
00366 
00380 extern _gdsl_bintree_t
00381 _gdsl_bintree_rotate_left (_gdsl_bintree_t* T
00382                );
00383 
00397 extern _gdsl_bintree_t
00398 _gdsl_bintree_rotate_right (_gdsl_bintree_t* T
00399                 );
00400 
00414 extern _gdsl_bintree_t
00415 _gdsl_bintree_rotate_left_right (_gdsl_bintree_t* T
00416                  );
00417 
00431 extern _gdsl_bintree_t
00432 _gdsl_bintree_rotate_right_left (_gdsl_bintree_t* T
00433                  );
00434 
00435 /******************************************************************************/
00436 /* Parse functions of low-level binary trees                                  */
00437 /******************************************************************************/
00438 
00457 extern _gdsl_bintree_t
00458 _gdsl_bintree_map_prefix (const _gdsl_bintree_t T,
00459               const gdsl_bintree_map_func_t MAP_F,
00460               void* USER_DATA
00461               );
00462 
00481 extern _gdsl_bintree_t
00482 _gdsl_bintree_map_infix (const _gdsl_bintree_t T,
00483              const gdsl_bintree_map_func_t MAP_F,
00484              void* USER_DATA
00485              );
00486 
00505 extern _gdsl_bintree_t
00506 _gdsl_bintree_map_postfix (const _gdsl_bintree_t T,
00507                const gdsl_bintree_map_func_t MAP_F,
00508                void* USER_DATA
00509                );
00510 
00511 /******************************************************************************/
00512 /* Input/output functions of low-level binary trees                           */
00513 /******************************************************************************/
00514 
00531 extern void
00532 _gdsl_bintree_write (const _gdsl_bintree_t T,
00533              const gdsl_write_func_t WRITE_F,
00534              FILE* OUTPUT_FILE,
00535              void* USER_DATA
00536              );
00537 
00555 extern void
00556 _gdsl_bintree_write_xml (const _gdsl_bintree_t T,
00557              const gdsl_write_func_t WRITE_F,
00558              FILE* OUTPUT_FILE,
00559              void* USER_DATA
00560              );
00561 
00579 extern void
00580 _gdsl_bintree_dump (const _gdsl_bintree_t T,
00581             const gdsl_write_func_t WRITE_F,
00582             FILE* OUTPUT_FILE,
00583             void* USER_DATA
00584             );
00585 
00586 /*
00587  * @}
00588  */
00589 
00590 
00591 #ifdef __cplusplus
00592 }
00593 #endif /* __cplusplus */
00594 
00595 
00596 #endif /* __GDSL_BINTREE_H_ */
00597 

Generated on Sun Oct 3 16:15:50 2004 for GDSL by doxygen 1.3.5