gdsl
1.8
|
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_heap.h,v $ 00019 * $Revision: 1.12 $ 00020 * $Date: 2015/02/17 12:22:56 $ 00021 */ 00022 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 00073 typedef struct heap* gdsl_heap_t; 00074 00075 /******************************************************************************/ 00076 /* Management functions of heaps */ 00077 /******************************************************************************/ 00078 00101 extern gdsl_heap_t 00102 gdsl_heap_alloc (const char* NAME, 00103 gdsl_alloc_func_t ALLOC_F, 00104 gdsl_free_func_t FREE_F, 00105 gdsl_compare_func_t COMP_F 00106 ); 00107 00121 extern void 00122 gdsl_heap_free (gdsl_heap_t H 00123 ); 00124 00138 extern void 00139 gdsl_heap_flush (gdsl_heap_t H 00140 ); 00141 00142 /******************************************************************************/ 00143 /* Consultation functions of heaps */ 00144 /******************************************************************************/ 00145 00155 extern const char* 00156 gdsl_heap_get_name (const gdsl_heap_t H 00157 ); 00158 00166 extern ulong 00167 gdsl_heap_get_size (const gdsl_heap_t H 00168 ); 00169 00180 extern gdsl_element_t 00181 gdsl_heap_get_top (const gdsl_heap_t H 00182 ); 00183 00192 extern bool 00193 gdsl_heap_is_empty (const gdsl_heap_t H 00194 ); 00195 00196 /******************************************************************************/ 00197 /* Modification functions of heaps */ 00198 /******************************************************************************/ 00199 00213 extern gdsl_heap_t 00214 gdsl_heap_set_name (gdsl_heap_t H, 00215 const char* NEW_NAME 00216 ); 00217 00232 extern gdsl_element_t 00233 gdsl_heap_set_top (gdsl_heap_t H, 00234 void* VALUE 00235 ); 00236 00255 extern gdsl_element_t 00256 gdsl_heap_insert (gdsl_heap_t H, 00257 void* VALUE 00258 ); 00259 00274 extern gdsl_element_t 00275 gdsl_heap_remove_top (gdsl_heap_t H 00276 ); 00277 00293 extern gdsl_heap_t 00294 gdsl_heap_delete_top (gdsl_heap_t H 00295 ); 00296 00297 /******************************************************************************/ 00298 /* Parse functions of heaps */ 00299 /******************************************************************************/ 00300 00316 extern gdsl_element_t 00317 gdsl_heap_map_forward (const gdsl_heap_t H, 00318 gdsl_map_func_t MAP_F, 00319 void* USER_DATA 00320 ); 00321 00322 /******************************************************************************/ 00323 /* Input/output functions of heaps */ 00324 /******************************************************************************/ 00325 00341 extern void 00342 gdsl_heap_write (const gdsl_heap_t H, 00343 gdsl_write_func_t WRITE_F, 00344 FILE* OUTPUT_FILE, 00345 void* USER_DATA 00346 ); 00347 00364 extern void 00365 gdsl_heap_write_xml (const gdsl_heap_t H, 00366 gdsl_write_func_t WRITE_F, 00367 FILE* OUTPUT_FILE, 00368 void* USER_DATA 00369 ); 00370 00387 extern void 00388 gdsl_heap_dump (const gdsl_heap_t H, 00389 gdsl_write_func_t WRITE_F, 00390 FILE* OUTPUT_FILE, 00391 void* USER_DATA 00392 ); 00393 00399 #ifdef __cplusplus 00400 } 00401 #endif /* __cplusplus */ 00402 00403 00404 #endif /* _GDSL_HEAP_H_ */ 00405 00406