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_stack.h,v $ 00019 * $Revision: 1.18 $ 00020 * $Date: 2015/02/17 12:22:57 $ 00021 */ 00022 00027 #ifndef _GDSL_STACK_H_ 00028 #define _GDSL_STACK_H_ 00029 00030 00031 #include <stdio.h> 00032 00033 00034 #include "gdsl_types.h" 00035 00036 #ifdef __cplusplus 00037 extern "C" 00038 { 00039 #endif /* __cplusplus */ 00040 00072 typedef struct _gdsl_stack* gdsl_stack_t; 00073 00074 /******************************************************************************/ 00075 /* Management functions of stacks */ 00076 /******************************************************************************/ 00077 00098 extern gdsl_stack_t 00099 gdsl_stack_alloc (const char* NAME, 00100 gdsl_alloc_func_t ALLOC_F, 00101 gdsl_free_func_t FREE_F 00102 ); 00103 00117 extern void 00118 gdsl_stack_free (gdsl_stack_t S 00119 ); 00120 00134 extern void 00135 gdsl_stack_flush (gdsl_stack_t S 00136 ); 00137 00138 /******************************************************************************/ 00139 /* Consultation functions of stacks */ 00140 /******************************************************************************/ 00141 00151 extern const char* 00152 gdsl_stack_get_name (const gdsl_stack_t S 00153 ); 00154 00162 extern ulong 00163 gdsl_stack_get_size (const gdsl_stack_t S 00164 ); 00165 00183 extern ulong 00184 gdsl_stack_get_growing_factor (const gdsl_stack_t S 00185 ); 00186 00195 extern bool 00196 gdsl_stack_is_empty (const gdsl_stack_t S 00197 ); 00198 00209 extern gdsl_element_t 00210 gdsl_stack_get_top (const gdsl_stack_t S 00211 ); 00212 00223 extern gdsl_element_t 00224 gdsl_stack_get_bottom (const gdsl_stack_t S 00225 ); 00226 00227 /******************************************************************************/ 00228 /* Modification functions of stacks */ 00229 /******************************************************************************/ 00230 00244 extern gdsl_stack_t 00245 gdsl_stack_set_name (gdsl_stack_t S, 00246 const char* NEW_NAME 00247 ); 00248 00267 extern void 00268 gdsl_stack_set_growing_factor (gdsl_stack_t S, 00269 ulong G 00270 ); 00271 00291 extern gdsl_element_t 00292 gdsl_stack_insert (gdsl_stack_t S, 00293 void* VALUE 00294 ); 00295 00308 extern gdsl_element_t 00309 gdsl_stack_remove (gdsl_stack_t S 00310 ); 00311 00312 /******************************************************************************/ 00313 /* Search functions of stacks */ 00314 /******************************************************************************/ 00315 00331 extern gdsl_element_t 00332 gdsl_stack_search (const gdsl_stack_t S, 00333 gdsl_compare_func_t COMP_F, 00334 void* VALUE 00335 ); 00336 00347 extern gdsl_element_t 00348 gdsl_stack_search_by_position (const gdsl_stack_t S, 00349 ulong POS 00350 ); 00351 00352 /******************************************************************************/ 00353 /* Parse functions of stacks */ 00354 /******************************************************************************/ 00355 00373 extern gdsl_element_t 00374 gdsl_stack_map_forward (const gdsl_stack_t S, 00375 gdsl_map_func_t MAP_F, 00376 void* USER_DATA 00377 ); 00378 00396 extern gdsl_element_t 00397 gdsl_stack_map_backward (const gdsl_stack_t S, 00398 gdsl_map_func_t MAP_F, 00399 void* USER_DATA 00400 ); 00401 00402 /******************************************************************************/ 00403 /* Input/output functions of stacks */ 00404 /******************************************************************************/ 00405 00421 extern void 00422 gdsl_stack_write (const gdsl_stack_t S, 00423 gdsl_write_func_t WRITE_F, 00424 FILE* OUTPUT_FILE, 00425 void* USER_DATA 00426 ); 00427 00444 extern void 00445 gdsl_stack_write_xml (gdsl_stack_t S, 00446 gdsl_write_func_t WRITE_F, 00447 FILE* OUTPUT_FILE, 00448 void* USER_DATA 00449 ); 00450 00467 extern void 00468 gdsl_stack_dump (gdsl_stack_t S, 00469 gdsl_write_func_t WRITE_F, 00470 FILE* OUTPUT_FILE, 00471 void* USER_DATA 00472 ); 00473 00474 00480 #ifdef __cplusplus 00481 } 00482 #endif /* __cplusplus */ 00483 00484 00485 #endif /* _GDSL_STACK_H_ */ 00486 00487