gdsl
1.7
|
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_heap.h,v $ 00021 * $Revision: 1.11 $ 00022 * $Date: 2006/03/07 16:32:58 $ 00023 */ 00024 00025 00026 #ifndef _GDSL_HEAP_H_ 00027 #define _GDSL_HEAP_H_ 00028 00029 00030 #include <stdio.h> 00031 00032 00033 #include "gdsl_types.h" 00034 00035 00036 #ifdef __cplusplus 00037 extern "C" 00038 { 00039 #endif /* __cplusplus */ 00040 00041 00054 typedef struct heap* gdsl_heap_t; 00055 00056 /******************************************************************************/ 00057 /* Management functions of heaps */ 00058 /******************************************************************************/ 00059 00082 extern gdsl_heap_t 00083 gdsl_heap_alloc (const char* NAME, 00084 gdsl_alloc_func_t ALLOC_F, 00085 gdsl_free_func_t FREE_F, 00086 gdsl_compare_func_t COMP_F 00087 ); 00088 00102 extern void 00103 gdsl_heap_free (gdsl_heap_t H 00104 ); 00105 00119 extern void 00120 gdsl_heap_flush (gdsl_heap_t H 00121 ); 00122 00123 /******************************************************************************/ 00124 /* Consultation functions of heaps */ 00125 /******************************************************************************/ 00126 00136 extern const char* 00137 gdsl_heap_get_name (const gdsl_heap_t H 00138 ); 00139 00147 extern ulong 00148 gdsl_heap_get_size (const gdsl_heap_t H 00149 ); 00150 00161 extern gdsl_element_t 00162 gdsl_heap_get_top (const gdsl_heap_t H 00163 ); 00164 00173 extern bool 00174 gdsl_heap_is_empty (const gdsl_heap_t H 00175 ); 00176 00177 /******************************************************************************/ 00178 /* Modification functions of heaps */ 00179 /******************************************************************************/ 00180 00194 extern gdsl_heap_t 00195 gdsl_heap_set_name (gdsl_heap_t H, 00196 const char* NEW_NAME 00197 ); 00198 00213 extern gdsl_element_t 00214 gdsl_heap_set_top (gdsl_heap_t H, 00215 void* VALUE 00216 ); 00217 00236 extern gdsl_element_t 00237 gdsl_heap_insert (gdsl_heap_t H, 00238 void* VALUE 00239 ); 00240 00255 extern gdsl_element_t 00256 gdsl_heap_remove_top (gdsl_heap_t H 00257 ); 00258 00274 extern gdsl_heap_t 00275 gdsl_heap_delete_top (gdsl_heap_t H 00276 ); 00277 00278 /******************************************************************************/ 00279 /* Parse functions of heaps */ 00280 /******************************************************************************/ 00281 00297 extern gdsl_element_t 00298 gdsl_heap_map_forward (const gdsl_heap_t H, 00299 gdsl_map_func_t MAP_F, 00300 void* USER_DATA 00301 ); 00302 00303 /******************************************************************************/ 00304 /* Input/output functions of heaps */ 00305 /******************************************************************************/ 00306 00322 extern void 00323 gdsl_heap_write (const gdsl_heap_t H, 00324 gdsl_write_func_t WRITE_F, 00325 FILE* OUTPUT_FILE, 00326 void* USER_DATA 00327 ); 00328 00345 extern void 00346 gdsl_heap_write_xml (const gdsl_heap_t H, 00347 gdsl_write_func_t WRITE_F, 00348 FILE* OUTPUT_FILE, 00349 void* USER_DATA 00350 ); 00351 00368 extern void 00369 gdsl_heap_dump (const gdsl_heap_t H, 00370 gdsl_write_func_t WRITE_F, 00371 FILE* OUTPUT_FILE, 00372 void* USER_DATA 00373 ); 00374 00375 /* 00376 * @} 00377 */ 00378 00379 00380 #ifdef __cplusplus 00381 } 00382 #endif /* __cplusplus */ 00383 00384 00385 #endif /* _GDSL_HEAP_H_ */ 00386 00387