gdsl
1.8
|
00001 /* 00002 * This file is part of the Generic Data Structures Library (GDSL). 00003 * Copyright (C) 1998-2015 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_heap.h,v $ 00021 * $Revision: 1.12 $ 00022 * $Date: 2015/02/17 12:22:56 $ 00023 */ 00024 00029 #ifndef _GDSL_HEAP_H_ 00030 #define _GDSL_HEAP_H_ 00031 00032 00033 #include <stdio.h> 00034 00035 00036 #include "gdsl_types.h" 00037 00038 00039 #ifdef __cplusplus 00040 extern "C" 00041 { 00042 #endif /* __cplusplus */ 00043 00044 00057 typedef struct heap* gdsl_heap_t; 00058 00059 /******************************************************************************/ 00060 /* Management functions of heaps */ 00061 /******************************************************************************/ 00062 00085 extern gdsl_heap_t 00086 gdsl_heap_alloc (const char* NAME, 00087 gdsl_alloc_func_t ALLOC_F, 00088 gdsl_free_func_t FREE_F, 00089 gdsl_compare_func_t COMP_F 00090 ); 00091 00105 extern void 00106 gdsl_heap_free (gdsl_heap_t H 00107 ); 00108 00122 extern void 00123 gdsl_heap_flush (gdsl_heap_t H 00124 ); 00125 00126 /******************************************************************************/ 00127 /* Consultation functions of heaps */ 00128 /******************************************************************************/ 00129 00139 extern const char* 00140 gdsl_heap_get_name (const gdsl_heap_t H 00141 ); 00142 00150 extern ulong 00151 gdsl_heap_get_size (const gdsl_heap_t H 00152 ); 00153 00164 extern gdsl_element_t 00165 gdsl_heap_get_top (const gdsl_heap_t H 00166 ); 00167 00176 extern bool 00177 gdsl_heap_is_empty (const gdsl_heap_t H 00178 ); 00179 00180 /******************************************************************************/ 00181 /* Modification functions of heaps */ 00182 /******************************************************************************/ 00183 00197 extern gdsl_heap_t 00198 gdsl_heap_set_name (gdsl_heap_t H, 00199 const char* NEW_NAME 00200 ); 00201 00216 extern gdsl_element_t 00217 gdsl_heap_set_top (gdsl_heap_t H, 00218 void* VALUE 00219 ); 00220 00239 extern gdsl_element_t 00240 gdsl_heap_insert (gdsl_heap_t H, 00241 void* VALUE 00242 ); 00243 00258 extern gdsl_element_t 00259 gdsl_heap_remove_top (gdsl_heap_t H 00260 ); 00261 00277 extern gdsl_heap_t 00278 gdsl_heap_delete_top (gdsl_heap_t H 00279 ); 00280 00281 /******************************************************************************/ 00282 /* Parse functions of heaps */ 00283 /******************************************************************************/ 00284 00300 extern gdsl_element_t 00301 gdsl_heap_map_forward (const gdsl_heap_t H, 00302 gdsl_map_func_t MAP_F, 00303 void* USER_DATA 00304 ); 00305 00306 /******************************************************************************/ 00307 /* Input/output functions of heaps */ 00308 /******************************************************************************/ 00309 00325 extern void 00326 gdsl_heap_write (const gdsl_heap_t H, 00327 gdsl_write_func_t WRITE_F, 00328 FILE* OUTPUT_FILE, 00329 void* USER_DATA 00330 ); 00331 00348 extern void 00349 gdsl_heap_write_xml (const gdsl_heap_t H, 00350 gdsl_write_func_t WRITE_F, 00351 FILE* OUTPUT_FILE, 00352 void* USER_DATA 00353 ); 00354 00371 extern void 00372 gdsl_heap_dump (const gdsl_heap_t H, 00373 gdsl_write_func_t WRITE_F, 00374 FILE* OUTPUT_FILE, 00375 void* USER_DATA 00376 ); 00377 00378 /* 00379 * @} 00380 */ 00381 00382 00383 #ifdef __cplusplus 00384 } 00385 #endif /* __cplusplus */ 00386 00387 00388 #endif /* _GDSL_HEAP_H_ */ 00389 00390