gdsl
1.8
|
00001 /* 00002 * This file is part of the Generic Data Structures Library (GDSL). 00003 * Copyright (C) 1998-2018 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 00019 /* 00020 * GDSL - Generic Data Structures Library 00021 * $RCSfile: gdsl_bstree.h,v $ 00022 * $Revision: 1.24 $ 00023 * $Date: 2015/02/17 12:22:56 $ 00024 */ 00025 00026 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 00054 typedef struct gdsl_bstree* gdsl_bstree_t; 00055 00056 /******************************************************************************/ 00057 /* Management functions of binary search trees */ 00058 /******************************************************************************/ 00059 00086 extern gdsl_bstree_t 00087 gdsl_bstree_alloc (const char* NAME, 00088 gdsl_alloc_func_t ALLOC_F, 00089 gdsl_free_func_t FREE_F, 00090 gdsl_compare_func_t COMP_F 00091 ); 00092 00106 extern void 00107 gdsl_bstree_free (gdsl_bstree_t T 00108 ); 00109 00124 extern void 00125 gdsl_bstree_flush (gdsl_bstree_t T 00126 ); 00127 00128 /******************************************************************************/ 00129 /* Consultation functions of binary search trees */ 00130 /******************************************************************************/ 00131 00141 extern const char* 00142 gdsl_bstree_get_name (const gdsl_bstree_t T 00143 ); 00144 00153 extern bool 00154 gdsl_bstree_is_empty (const gdsl_bstree_t T 00155 ); 00156 00164 extern gdsl_element_t 00165 gdsl_bstree_get_root (const gdsl_bstree_t T 00166 ); 00167 00176 extern ulong 00177 gdsl_bstree_get_size (const gdsl_bstree_t T 00178 ); 00179 00188 extern ulong 00189 gdsl_bstree_get_height (const gdsl_bstree_t T 00190 ); 00191 00192 /******************************************************************************/ 00193 /* Modification functions of binary search trees */ 00194 /******************************************************************************/ 00195 00209 extern gdsl_bstree_t 00210 gdsl_bstree_set_name (gdsl_bstree_t T, 00211 const char* NEW_NAME 00212 ); 00213 00236 extern gdsl_element_t 00237 gdsl_bstree_insert (gdsl_bstree_t T, 00238 void* VALUE, 00239 int* RESULT 00240 ); 00241 00260 extern gdsl_element_t 00261 gdsl_bstree_remove (gdsl_bstree_t T, 00262 void* VALUE 00263 ); 00264 00284 extern gdsl_bstree_t 00285 gdsl_bstree_delete (gdsl_bstree_t T, 00286 void* VALUE 00287 ); 00288 00289 /******************************************************************************/ 00290 /* Search functions of binary search trees */ 00291 /******************************************************************************/ 00292 00312 extern gdsl_element_t 00313 gdsl_bstree_search (const gdsl_bstree_t T, 00314 gdsl_compare_func_t COMP_F, 00315 void* VALUE 00316 ); 00317 00318 /******************************************************************************/ 00319 /* Parse functions of binary search trees */ 00320 /******************************************************************************/ 00321 00340 extern gdsl_element_t 00341 gdsl_bstree_map_prefix (const gdsl_bstree_t T, 00342 gdsl_map_func_t MAP_F, 00343 void* USER_DATA 00344 ); 00345 00364 extern gdsl_element_t 00365 gdsl_bstree_map_infix (const gdsl_bstree_t T, 00366 gdsl_map_func_t MAP_F, 00367 void* USER_DATA 00368 ); 00369 00388 extern gdsl_element_t 00389 gdsl_bstree_map_postfix (const gdsl_bstree_t T, 00390 gdsl_map_func_t MAP_F, 00391 void* USER_DATA 00392 ); 00393 00394 /******************************************************************************/ 00395 /* Input/output functions of binary search trees */ 00396 /******************************************************************************/ 00397 00414 extern void 00415 gdsl_bstree_write (const gdsl_bstree_t T, 00416 gdsl_write_func_t WRITE_F, 00417 FILE* OUTPUT_FILE, 00418 void* USER_DATA 00419 ); 00420 00439 extern void 00440 gdsl_bstree_write_xml (const gdsl_bstree_t T, 00441 gdsl_write_func_t WRITE_F, 00442 FILE* OUTPUT_FILE, 00443 void* USER_DATA 00444 ); 00445 00463 extern void 00464 gdsl_bstree_dump (const gdsl_bstree_t T, 00465 gdsl_write_func_t WRITE_F, 00466 FILE* OUTPUT_FILE, 00467 void* USER_DATA 00468 ); 00469 00475 #ifdef __cplusplus 00476 } 00477 #endif /* __cplusplus */ 00478 00479 00480 #endif /* _GDSL_BSTREE_H_ */ 00481 00482