gdsl  1.8
gdsl_heap.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-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_heap.h,v $
00022  * $Revision: 1.12 $
00023  * $Date: 2015/02/17 12:22:56 $
00024  */
00025 
00026 
00027 #ifndef _GDSL_HEAP_H_
00028 #define _GDSL_HEAP_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 
00055 typedef struct heap* gdsl_heap_t;
00056 
00057 /******************************************************************************/
00058 /* Management functions of heaps                                              */
00059 /******************************************************************************/
00060 
00083 extern gdsl_heap_t
00084 gdsl_heap_alloc (const char* NAME,
00085          gdsl_alloc_func_t ALLOC_F,
00086          gdsl_free_func_t FREE_F,
00087          gdsl_compare_func_t COMP_F
00088          );
00089 
00103 extern void
00104 gdsl_heap_free (gdsl_heap_t H
00105         );
00106 
00120 extern void
00121 gdsl_heap_flush (gdsl_heap_t H
00122          );
00123 
00124 /******************************************************************************/
00125 /* Consultation functions of heaps                                            */
00126 /******************************************************************************/
00127 
00137 extern const char*
00138 gdsl_heap_get_name (const gdsl_heap_t H
00139             );
00140 
00148 extern ulong
00149 gdsl_heap_get_size (const gdsl_heap_t H
00150             );
00151 
00162 extern gdsl_element_t
00163 gdsl_heap_get_top (const gdsl_heap_t H
00164            );
00165 
00174 extern bool 
00175 gdsl_heap_is_empty (const gdsl_heap_t H
00176             );
00177 
00178 /******************************************************************************/
00179 /* Modification functions of heaps                                            */
00180 /******************************************************************************/
00181   
00195 extern gdsl_heap_t
00196 gdsl_heap_set_name (gdsl_heap_t H,
00197             const char* NEW_NAME
00198             );
00199 
00214 extern gdsl_element_t
00215 gdsl_heap_set_top (gdsl_heap_t H, 
00216            void* VALUE
00217            );
00218 
00237 extern gdsl_element_t
00238 gdsl_heap_insert (gdsl_heap_t H,
00239           void* VALUE
00240           );
00241 
00256 extern gdsl_element_t
00257 gdsl_heap_remove_top (gdsl_heap_t H
00258               );
00259 
00275 extern gdsl_heap_t
00276 gdsl_heap_delete_top (gdsl_heap_t H
00277               );
00278 
00279 /******************************************************************************/
00280 /* Parse functions of heaps                                                   */
00281 /******************************************************************************/
00282 
00298 extern gdsl_element_t
00299 gdsl_heap_map_forward (const gdsl_heap_t H,
00300                gdsl_map_func_t MAP_F,
00301                void* USER_DATA
00302                );
00303 
00304 /******************************************************************************/
00305 /* Input/output functions of heaps                                            */
00306 /******************************************************************************/
00307 
00323 extern void
00324 gdsl_heap_write (const gdsl_heap_t H,
00325          gdsl_write_func_t WRITE_F,
00326          FILE* OUTPUT_FILE,
00327          void* USER_DATA
00328          );
00329 
00346 extern void
00347 gdsl_heap_write_xml (const gdsl_heap_t H,
00348              gdsl_write_func_t WRITE_F,
00349              FILE* OUTPUT_FILE,
00350              void* USER_DATA
00351              );
00352 
00369 extern void
00370 gdsl_heap_dump (const gdsl_heap_t H,
00371         gdsl_write_func_t WRITE_F,
00372         FILE* OUTPUT_FILE,
00373         void* USER_DATA
00374         );
00375 
00381 #ifdef __cplusplus
00382 }
00383 #endif /* __cplusplus */
00384 
00385 
00386 #endif /* _GDSL_HEAP_H_ */
00387 
00388