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 00041 00054 typedef struct _gdsl_stack* gdsl_stack_t; 00055 00056 /******************************************************************************/ 00057 /* Management functions of stacks */ 00058 /******************************************************************************/ 00059 00080 extern gdsl_stack_t 00081 gdsl_stack_alloc (const char* NAME, 00082 gdsl_alloc_func_t ALLOC_F, 00083 gdsl_free_func_t FREE_F 00084 ); 00085 00099 extern void 00100 gdsl_stack_free (gdsl_stack_t S 00101 ); 00102 00116 extern void 00117 gdsl_stack_flush (gdsl_stack_t S 00118 ); 00119 00120 /******************************************************************************/ 00121 /* Consultation functions of stacks */ 00122 /******************************************************************************/ 00123 00133 extern const char* 00134 gdsl_stack_get_name (const gdsl_stack_t S 00135 ); 00136 00144 extern ulong 00145 gdsl_stack_get_size (const gdsl_stack_t S 00146 ); 00147 00165 extern ulong 00166 gdsl_stack_get_growing_factor (const gdsl_stack_t S 00167 ); 00168 00177 extern bool 00178 gdsl_stack_is_empty (const gdsl_stack_t S 00179 ); 00180 00191 extern gdsl_element_t 00192 gdsl_stack_get_top (const gdsl_stack_t S 00193 ); 00194 00205 extern gdsl_element_t 00206 gdsl_stack_get_bottom (const gdsl_stack_t S 00207 ); 00208 00209 /******************************************************************************/ 00210 /* Modification functions of stacks */ 00211 /******************************************************************************/ 00212 00226 extern gdsl_stack_t 00227 gdsl_stack_set_name (gdsl_stack_t S, 00228 const char* NEW_NAME 00229 ); 00230 00249 extern void 00250 gdsl_stack_set_growing_factor (gdsl_stack_t S, 00251 ulong G 00252 ); 00253 00273 extern gdsl_element_t 00274 gdsl_stack_insert (gdsl_stack_t S, 00275 void* VALUE 00276 ); 00277 00290 extern gdsl_element_t 00291 gdsl_stack_remove (gdsl_stack_t S 00292 ); 00293 00294 /******************************************************************************/ 00295 /* Search functions of stacks */ 00296 /******************************************************************************/ 00297 00313 extern gdsl_element_t 00314 gdsl_stack_search (const gdsl_stack_t S, 00315 gdsl_compare_func_t COMP_F, 00316 void* VALUE 00317 ); 00318 00329 extern gdsl_element_t 00330 gdsl_stack_search_by_position (const gdsl_stack_t S, 00331 ulong POS 00332 ); 00333 00334 /******************************************************************************/ 00335 /* Parse functions of stacks */ 00336 /******************************************************************************/ 00337 00355 extern gdsl_element_t 00356 gdsl_stack_map_forward (const gdsl_stack_t S, 00357 gdsl_map_func_t MAP_F, 00358 void* USER_DATA 00359 ); 00360 00378 extern gdsl_element_t 00379 gdsl_stack_map_backward (const gdsl_stack_t S, 00380 gdsl_map_func_t MAP_F, 00381 void* USER_DATA 00382 ); 00383 00384 /******************************************************************************/ 00385 /* Input/output functions of stacks */ 00386 /******************************************************************************/ 00387 00403 extern void 00404 gdsl_stack_write (const gdsl_stack_t S, 00405 gdsl_write_func_t WRITE_F, 00406 FILE* OUTPUT_FILE, 00407 void* USER_DATA 00408 ); 00409 00426 extern void 00427 gdsl_stack_write_xml (gdsl_stack_t S, 00428 gdsl_write_func_t WRITE_F, 00429 FILE* OUTPUT_FILE, 00430 void* USER_DATA 00431 ); 00432 00449 extern void 00450 gdsl_stack_dump (gdsl_stack_t S, 00451 gdsl_write_func_t WRITE_F, 00452 FILE* OUTPUT_FILE, 00453 void* USER_DATA 00454 ); 00455 00456 00457 /* 00458 * @} 00459 */ 00460 00461 00462 #ifdef __cplusplus 00463 } 00464 #endif /* __cplusplus */ 00465 00466 00467 #endif /* _GDSL_STACK_H_ */ 00468 00469