00001 /*! \file stack.h 00002 Header file for stack.c 00003 */ 00004 00005 #ifndef STACK_H 00006 #define STACK_H 00007 00008 #ifdef __cplusplus 00009 extern "C" { 00010 #endif 00011 00012 #include <stdlib.h> 00013 #include "list.h" 00014 00015 /*! \brief A stack is implemented as a linked list. 00016 */ 00017 00018 typedef List Stack; 00019 00020 /* ---------------------------------------------------------- */ 00021 /* Public API */ 00022 /* ---------------------------------------------------------- */ 00023 00024 int stack_push(Stack *pile, const void *donnee); 00025 int stack_pop(Stack *pile, void **donnee); 00026 00027 /*! \brief Initialize the stack. The prototype for this function is the same than for list_init(). 00028 Please consult the documentation for the linked list API. 00029 */ 00030 00031 #define stack_init list_init 00032 00033 /*! \brief Free all memory allocated for the stack. The prototype for this function is the same than for list_destroy(). 00034 Please consult the documentation for the linked list API. 00035 */ 00036 00037 #define stack_destroy list_destroy 00038 00039 /*! \brief Return a pointer to the element at the top of the list (the element is <B>NOT</B> extracted from the list). 00040 \param Pointer to a stack data structure. 00041 */ 00042 00043 #define stack_peek(pile)\ 00044 ((pile)->tete == NULL ? NULL : (pile)->tete->donnee) 00045 00046 /*! \brief Return the numder of element in the stack. This macro is identical to the macro <i>list_size</i> used for linked list. 00047 Please consult the documentation for the linked list API. 00048 */ 00049 00050 #define stack_size list_size 00051 00052 #endif 00053 00054 #ifdef __cplusplus 00055 } 00056 #endif 00057