gdsl  1.8
gdsl_bstree.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-2015 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_bstree.h,v $
00021  * $Revision: 1.24 $
00022  * $Date: 2015/02/17 12:22:56 $
00023  */
00024 
00029 #ifndef _GDSL_BSTREE_H_
00030 #define _GDSL_BSTREE_H_
00031 
00032 
00033 #include <stdio.h>
00034 
00035 
00036 #include "gdsl_types.h"
00037 
00038 
00039 #ifdef __cplusplus
00040 extern "C" 
00041 {
00042 #endif /* __cplusplus */
00043 
00044 
00056 typedef struct gdsl_bstree* gdsl_bstree_t;
00057 
00058 /******************************************************************************/
00059 /* Management functions of binary search trees                                */
00060 /******************************************************************************/
00061 
00088 extern gdsl_bstree_t
00089 gdsl_bstree_alloc (const char* NAME,
00090            gdsl_alloc_func_t ALLOC_F,
00091            gdsl_free_func_t FREE_F,
00092            gdsl_compare_func_t COMP_F
00093            );
00094 
00108 extern void
00109 gdsl_bstree_free (gdsl_bstree_t T
00110           );
00111 
00126 extern void
00127 gdsl_bstree_flush (gdsl_bstree_t T
00128            );
00129 
00130 /******************************************************************************/
00131 /* Consultation functions of binary search trees                              */
00132 /******************************************************************************/
00133 
00143 extern const char*
00144 gdsl_bstree_get_name (const gdsl_bstree_t T
00145               );
00146 
00155 extern bool
00156 gdsl_bstree_is_empty (const gdsl_bstree_t T
00157               );
00158 
00166 extern gdsl_element_t
00167 gdsl_bstree_get_root (const gdsl_bstree_t T
00168               );
00169 
00178 extern ulong
00179 gdsl_bstree_get_size (const gdsl_bstree_t T
00180               );
00181 
00190 extern ulong
00191 gdsl_bstree_get_height (const gdsl_bstree_t T
00192             );
00193 
00194 /******************************************************************************/
00195 /* Modification functions of binary search trees                              */
00196 /******************************************************************************/
00197 
00211 extern gdsl_bstree_t
00212 gdsl_bstree_set_name (gdsl_bstree_t T,
00213               const char* NEW_NAME
00214               );
00215 
00238 extern gdsl_element_t
00239 gdsl_bstree_insert (gdsl_bstree_t T,
00240             void* VALUE,
00241             int* RESULT
00242             );
00243 
00262 extern gdsl_element_t
00263 gdsl_bstree_remove (gdsl_bstree_t T,
00264             void* VALUE
00265             );
00266 
00286 extern gdsl_bstree_t
00287 gdsl_bstree_delete (gdsl_bstree_t T,
00288             void* VALUE
00289             );
00290   
00291 /******************************************************************************/
00292 /* Search functions of binary search trees                                    */
00293 /******************************************************************************/
00294 
00314 extern gdsl_element_t
00315 gdsl_bstree_search (const gdsl_bstree_t T,
00316             gdsl_compare_func_t COMP_F,
00317             void* VALUE
00318             );
00319 
00320 /******************************************************************************/
00321 /* Parse functions of binary search trees                                     */
00322 /******************************************************************************/
00323 
00342 extern gdsl_element_t
00343 gdsl_bstree_map_prefix (const gdsl_bstree_t T,
00344             gdsl_map_func_t MAP_F,
00345             void* USER_DATA
00346             );
00347 
00366 extern gdsl_element_t
00367 gdsl_bstree_map_infix (const gdsl_bstree_t T,
00368                gdsl_map_func_t MAP_F,
00369                void* USER_DATA
00370                );
00371 
00390 extern gdsl_element_t
00391 gdsl_bstree_map_postfix (const gdsl_bstree_t T,
00392              gdsl_map_func_t MAP_F,
00393              void* USER_DATA
00394              );
00395 
00396 /******************************************************************************/
00397 /* Input/output functions of binary search trees                              */
00398 /******************************************************************************/
00399 
00416 extern void
00417 gdsl_bstree_write (const gdsl_bstree_t T,
00418            gdsl_write_func_t WRITE_F,
00419            FILE* OUTPUT_FILE,
00420            void* USER_DATA
00421            );
00422 
00441 extern void
00442 gdsl_bstree_write_xml (const gdsl_bstree_t T,
00443                gdsl_write_func_t WRITE_F,
00444                FILE* OUTPUT_FILE,
00445                void* USER_DATA
00446                );
00447 
00465 extern void
00466 gdsl_bstree_dump (const gdsl_bstree_t T,
00467           gdsl_write_func_t WRITE_F,
00468           FILE* OUTPUT_FILE,
00469           void* USER_DATA
00470           );
00471 
00472 /*
00473  * @}
00474  */
00475 
00476 
00477 #ifdef __cplusplus
00478 }
00479 #endif /* __cplusplus */
00480 
00481 
00482 #endif /* _GDSL_BSTREE_H_ */
00483 
00484