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_stack.h,v $ 00021 * $Revision: 1.18 $ 00022 * $Date: 2015/02/17 12:22:57 $ 00023 */ 00024 00029 #ifndef _GDSL_STACK_H_ 00030 #define _GDSL_STACK_H_ 00031 00032 00033 #include <stdio.h> 00034 00035 00036 #include "gdsl_types.h" 00037 00038 #ifdef __cplusplus 00039 extern "C" 00040 { 00041 #endif /* __cplusplus */ 00042 00043 00056 typedef struct _gdsl_stack* gdsl_stack_t; 00057 00058 /******************************************************************************/ 00059 /* Management functions of stacks */ 00060 /******************************************************************************/ 00061 00082 extern gdsl_stack_t 00083 gdsl_stack_alloc (const char* NAME, 00084 gdsl_alloc_func_t ALLOC_F, 00085 gdsl_free_func_t FREE_F 00086 ); 00087 00101 extern void 00102 gdsl_stack_free (gdsl_stack_t S 00103 ); 00104 00118 extern void 00119 gdsl_stack_flush (gdsl_stack_t S 00120 ); 00121 00122 /******************************************************************************/ 00123 /* Consultation functions of stacks */ 00124 /******************************************************************************/ 00125 00135 extern const char* 00136 gdsl_stack_get_name (const gdsl_stack_t S 00137 ); 00138 00146 extern ulong 00147 gdsl_stack_get_size (const gdsl_stack_t S 00148 ); 00149 00167 extern ulong 00168 gdsl_stack_get_growing_factor (const gdsl_stack_t S 00169 ); 00170 00179 extern bool 00180 gdsl_stack_is_empty (const gdsl_stack_t S 00181 ); 00182 00193 extern gdsl_element_t 00194 gdsl_stack_get_top (const gdsl_stack_t S 00195 ); 00196 00207 extern gdsl_element_t 00208 gdsl_stack_get_bottom (const gdsl_stack_t S 00209 ); 00210 00211 /******************************************************************************/ 00212 /* Modification functions of stacks */ 00213 /******************************************************************************/ 00214 00228 extern gdsl_stack_t 00229 gdsl_stack_set_name (gdsl_stack_t S, 00230 const char* NEW_NAME 00231 ); 00232 00251 extern void 00252 gdsl_stack_set_growing_factor (gdsl_stack_t S, 00253 ulong G 00254 ); 00255 00275 extern gdsl_element_t 00276 gdsl_stack_insert (gdsl_stack_t S, 00277 void* VALUE 00278 ); 00279 00292 extern gdsl_element_t 00293 gdsl_stack_remove (gdsl_stack_t S 00294 ); 00295 00296 /******************************************************************************/ 00297 /* Search functions of stacks */ 00298 /******************************************************************************/ 00299 00315 extern gdsl_element_t 00316 gdsl_stack_search (const gdsl_stack_t S, 00317 gdsl_compare_func_t COMP_F, 00318 void* VALUE 00319 ); 00320 00331 extern gdsl_element_t 00332 gdsl_stack_search_by_position (const gdsl_stack_t S, 00333 ulong POS 00334 ); 00335 00336 /******************************************************************************/ 00337 /* Parse functions of stacks */ 00338 /******************************************************************************/ 00339 00357 extern gdsl_element_t 00358 gdsl_stack_map_forward (const gdsl_stack_t S, 00359 gdsl_map_func_t MAP_F, 00360 void* USER_DATA 00361 ); 00362 00380 extern gdsl_element_t 00381 gdsl_stack_map_backward (const gdsl_stack_t S, 00382 gdsl_map_func_t MAP_F, 00383 void* USER_DATA 00384 ); 00385 00386 /******************************************************************************/ 00387 /* Input/output functions of stacks */ 00388 /******************************************************************************/ 00389 00405 extern void 00406 gdsl_stack_write (const gdsl_stack_t S, 00407 gdsl_write_func_t WRITE_F, 00408 FILE* OUTPUT_FILE, 00409 void* USER_DATA 00410 ); 00411 00428 extern void 00429 gdsl_stack_write_xml (gdsl_stack_t S, 00430 gdsl_write_func_t WRITE_F, 00431 FILE* OUTPUT_FILE, 00432 void* USER_DATA 00433 ); 00434 00451 extern void 00452 gdsl_stack_dump (gdsl_stack_t S, 00453 gdsl_write_func_t WRITE_F, 00454 FILE* OUTPUT_FILE, 00455 void* USER_DATA 00456 ); 00457 00458 00459 /* 00460 * @} 00461 */ 00462 00463 00464 #ifdef __cplusplus 00465 } 00466 #endif /* __cplusplus */ 00467 00468 00469 #endif /* _GDSL_STACK_H_ */ 00470 00471