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-2017 Nicolas Darnis <ndarnis@free.fr>.
00004  *
00005  * GDSL is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * GDSL 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 GDSL.  If not, see <http://www.gnu.org/licenses/>. 
00017  *
00018  * $RCSfile: gdsl_bstree.h,v $
00019  * $Revision: 1.24 $
00020  * $Date: 2015/02/17 12:22:56 $
00021  */
00022 
00027 #ifndef _GDSL_BSTREE_H_
00028 #define _GDSL_BSTREE_H_
00029 
00030 
00031 #include <stdio.h>
00032 
00033 
00034 #include "gdsl_types.h"
00035 
00036 
00037 #ifdef __cplusplus
00038 extern "C" 
00039 {
00040 #endif /* __cplusplus */
00041 
00072 typedef struct gdsl_bstree* gdsl_bstree_t;
00073 
00074 /******************************************************************************/
00075 /* Management functions of binary search trees                                */
00076 /******************************************************************************/
00077 
00104 extern gdsl_bstree_t
00105 gdsl_bstree_alloc (const char* NAME,
00106            gdsl_alloc_func_t ALLOC_F,
00107            gdsl_free_func_t FREE_F,
00108            gdsl_compare_func_t COMP_F
00109            );
00110 
00124 extern void
00125 gdsl_bstree_free (gdsl_bstree_t T
00126           );
00127 
00142 extern void
00143 gdsl_bstree_flush (gdsl_bstree_t T
00144            );
00145 
00146 /******************************************************************************/
00147 /* Consultation functions of binary search trees                              */
00148 /******************************************************************************/
00149 
00159 extern const char*
00160 gdsl_bstree_get_name (const gdsl_bstree_t T
00161               );
00162 
00171 extern bool
00172 gdsl_bstree_is_empty (const gdsl_bstree_t T
00173               );
00174 
00182 extern gdsl_element_t
00183 gdsl_bstree_get_root (const gdsl_bstree_t T
00184               );
00185 
00194 extern ulong
00195 gdsl_bstree_get_size (const gdsl_bstree_t T
00196               );
00197 
00206 extern ulong
00207 gdsl_bstree_get_height (const gdsl_bstree_t T
00208             );
00209 
00210 /******************************************************************************/
00211 /* Modification functions of binary search trees                              */
00212 /******************************************************************************/
00213 
00227 extern gdsl_bstree_t
00228 gdsl_bstree_set_name (gdsl_bstree_t T,
00229               const char* NEW_NAME
00230               );
00231 
00254 extern gdsl_element_t
00255 gdsl_bstree_insert (gdsl_bstree_t T,
00256             void* VALUE,
00257             int* RESULT
00258             );
00259 
00278 extern gdsl_element_t
00279 gdsl_bstree_remove (gdsl_bstree_t T,
00280             void* VALUE
00281             );
00282 
00302 extern gdsl_bstree_t
00303 gdsl_bstree_delete (gdsl_bstree_t T,
00304             void* VALUE
00305             );
00306   
00307 /******************************************************************************/
00308 /* Search functions of binary search trees                                    */
00309 /******************************************************************************/
00310 
00330 extern gdsl_element_t
00331 gdsl_bstree_search (const gdsl_bstree_t T,
00332             gdsl_compare_func_t COMP_F,
00333             void* VALUE
00334             );
00335 
00336 /******************************************************************************/
00337 /* Parse functions of binary search trees                                     */
00338 /******************************************************************************/
00339 
00358 extern gdsl_element_t
00359 gdsl_bstree_map_prefix (const gdsl_bstree_t T,
00360             gdsl_map_func_t MAP_F,
00361             void* USER_DATA
00362             );
00363 
00382 extern gdsl_element_t
00383 gdsl_bstree_map_infix (const gdsl_bstree_t T,
00384                gdsl_map_func_t MAP_F,
00385                void* USER_DATA
00386                );
00387 
00406 extern gdsl_element_t
00407 gdsl_bstree_map_postfix (const gdsl_bstree_t T,
00408              gdsl_map_func_t MAP_F,
00409              void* USER_DATA
00410              );
00411 
00412 /******************************************************************************/
00413 /* Input/output functions of binary search trees                              */
00414 /******************************************************************************/
00415 
00432 extern void
00433 gdsl_bstree_write (const gdsl_bstree_t T,
00434            gdsl_write_func_t WRITE_F,
00435            FILE* OUTPUT_FILE,
00436            void* USER_DATA
00437            );
00438 
00457 extern void
00458 gdsl_bstree_write_xml (const gdsl_bstree_t T,
00459                gdsl_write_func_t WRITE_F,
00460                FILE* OUTPUT_FILE,
00461                void* USER_DATA
00462                );
00463 
00481 extern void
00482 gdsl_bstree_dump (const gdsl_bstree_t T,
00483           gdsl_write_func_t WRITE_F,
00484           FILE* OUTPUT_FILE,
00485           void* USER_DATA
00486           );
00487 
00493 #ifdef __cplusplus
00494 }
00495 #endif /* __cplusplus */
00496 
00497 
00498 #endif /* _GDSL_BSTREE_H_ */
00499 
00500