gdsl  1.7
gdsl_rbtree.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-2006 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_rbtree.h,v $
00021  * $Revision: 1.20 $
00022  * $Date: 2006/03/04 16:32:05 $
00023  */
00024 
00025 
00026 #ifndef _GDSL_RBTREE_H_
00027 #define _GDSL_RBTREE_H_
00028 
00029 
00030 #include "gdsl_types.h"
00031 #include "_gdsl_bintree.h"
00032 #include "gdsl_macros.h"
00033 
00034 
00035 #ifdef __cplusplus
00036 extern "C" 
00037 {
00038 #endif /* __cplusplus */
00039 
00040 
00052 typedef struct gdsl_rbtree* gdsl_rbtree_t;
00053 
00054 /******************************************************************************/
00055 /* Management functions of red-black trees                                    */
00056 /******************************************************************************/
00057 
00081 extern gdsl_rbtree_t
00082 gdsl_rbtree_alloc (const char* NAME,
00083            gdsl_alloc_func_t ALLOC_F,
00084            gdsl_free_func_t FREE_F,
00085            gdsl_compare_func_t COMP_F
00086            );
00087   
00101 extern void 
00102 gdsl_rbtree_free (gdsl_rbtree_t T
00103           );
00104 
00117 extern void 
00118 gdsl_rbtree_flush (gdsl_rbtree_t T
00119            );
00120 
00121 /******************************************************************************/
00122 /* Consultation functions of red-black trees                                  */
00123 /******************************************************************************/
00124 
00134 extern char*
00135 gdsl_rbtree_get_name (const gdsl_rbtree_t T
00136               );
00137 
00146 extern bool
00147 gdsl_rbtree_is_empty (const gdsl_rbtree_t T
00148               );
00149 
00157 extern gdsl_element_t
00158 gdsl_rbtree_get_root (const gdsl_rbtree_t T
00159               );
00160 
00169 extern ulong
00170 gdsl_rbtree_get_size (const gdsl_rbtree_t T
00171               );
00172 
00181 extern ulong
00182 gdsl_rbtree_height (const gdsl_rbtree_t T
00183             );
00184 
00185 /******************************************************************************/
00186 /* Modification functions of red-black trees                                  */
00187 /******************************************************************************/
00188 
00202 extern gdsl_rbtree_t
00203 gdsl_rbtree_set_name (gdsl_rbtree_t T,
00204               const char* NEW_NAME
00205               );
00206 
00229 extern gdsl_element_t
00230 gdsl_rbtree_insert (gdsl_rbtree_t T,
00231             void* VALUE,
00232             int* RESULT
00233             );
00234 
00251 extern gdsl_element_t
00252 gdsl_rbtree_remove (gdsl_rbtree_t T,
00253             void* VALUE
00254             );
00255 
00273 extern gdsl_rbtree_t
00274 gdsl_rbtree_delete (gdsl_rbtree_t T,
00275             void* VALUE
00276             );
00277 
00278 /******************************************************************************/
00279 /* Search functions of red-black trees                                        */
00280 /******************************************************************************/
00281 
00301 extern gdsl_element_t
00302 gdsl_rbtree_search (const gdsl_rbtree_t T,
00303             gdsl_compare_func_t COMP_F,
00304             void* VALUE
00305             );
00306 
00307 /******************************************************************************/
00308 /* Parse functions of red-black trees                                         */
00309 /******************************************************************************/
00310 
00329 extern gdsl_element_t
00330 gdsl_rbtree_map_prefix (const gdsl_rbtree_t T,
00331             gdsl_map_func_t MAP_F,
00332             void* USER_DATA
00333             );
00334 
00353 extern gdsl_element_t
00354 gdsl_rbtree_map_infix (const gdsl_rbtree_t T,
00355                gdsl_map_func_t MAP_F,
00356                void* USER_DATA
00357                );
00358 
00377 extern gdsl_element_t
00378 gdsl_rbtree_map_postfix (const gdsl_rbtree_t T,
00379              gdsl_map_func_t MAP_F,
00380              void* USER_DATA
00381              );
00382 
00383 /******************************************************************************/
00384 /* Input/output functions of red-black trees                                  */
00385 /******************************************************************************/
00386 
00403 extern void
00404 gdsl_rbtree_write (const gdsl_rbtree_t T,
00405            gdsl_write_func_t WRITE_F,
00406            FILE* OUTPUT_FILE,
00407            void* USER_DATA
00408            );
00409 
00428 extern void
00429 gdsl_rbtree_write_xml (const gdsl_rbtree_t T,
00430                gdsl_write_func_t WRITE_F,
00431                FILE* OUTPUT_FILE,
00432                void* USER_DATA
00433                );
00434 
00452 extern void
00453 gdsl_rbtree_dump (const gdsl_rbtree_t T,
00454           gdsl_write_func_t WRITE_F,
00455           FILE* OUTPUT_FILE,
00456           void* USER_DATA
00457           );
00458 
00459 /*
00460  * @}
00461  */
00462 
00463 
00464 #ifdef __cplusplus
00465 }
00466 #endif /* __cplusplus */
00467 
00468 
00469 #endif /* _GDSL_RBTREE_H_ */
00470 
00471