00001 /* Copyright 2009 (c) ENSI de Bourges 00002 * 88 boulevard Lahitolle, 18020 Bourges Cedex, France 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00024 #ifndef __STACK_H 00025 #define __STACK_H 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 #include <glib.h> 00030 00031 00032 00033 typedef struct __Stack { 00034 gpointer *elems; 00035 gint nbelems; 00036 gint top; 00037 } Stack; 00038 00039 00040 00041 Stack *stack_new (); 00042 gpointer stack_pop (Stack *stack); 00043 void stack_push (Stack *stack, gpointer value); 00044 void stack_free (Stack *stack); 00045 void stack_free_with_data (Stack *stack); 00046 gpointer stack_remove_nth (Stack *stack, guint n); 00047 void stack_insert_before_nth (Stack *stack, gpointer value, guint n); 00048 gint stack_search (Stack *stack, gpointer target); 00049 void stack_swap_mth_nth (Stack *stack, gint m, gint n); 00050 #ifdef __cplusplus 00051 } 00052 #endif 00053 #endif