00001 #ifndef _STACK_H 00002 #define _STACK_H 00003 00004 #include <dbLkList.h> 00005 00006 /** function pointers */ 00007 typedef struct Stack *StackP; 00008 typedef void (StDestroyFunction)(StackP st, void *object); 00009 00010 /** this is the stack structure, its just a double linked list 00011 * we insert tail and remove tail. 00012 */ 00013 typedef struct _Stack_ { 00014 DbLkList *elements; 00015 StDestroyFunction *destroyFunction; 00016 } Stack; 00017 //typedef struct Stack *StackP; 00018 //typedef void (StDestroyFunction)(StackP st, void *object); 00019 00020 00021 typedef enum { ST_DM_KEEP=0, ST_DM_FREE } StDestroyMode; 00022 00023 00024 /** creates an empty stack 00025 * return the stack created 00026 */ 00027 Stack *stCreate(); 00028 /** destroys the stack, mode defines if objects will be destroyed too 00029 * @param stackAddress the address of the stack, which will be freed and NULLed 00030 * @param mode how we destroy the stack 00031 */ 00032 void stDestroy(Stack **stackAddress, StDestroyMode mode); 00033 00034 /** inserts an element to the stack */ 00035 int stPush(Stack *st, void *object); 00036 /** fill object with the top of the stack, which is removed */ 00037 int stPop(Stack *st, void **objectAddress); 00038 /** get stack top, but does not remove it */ 00039 int stGetTop(Stack *st, void **objectAddress); 00040 /** returns the number of elements in the stack */ 00041 int stNumElements(Stack *st); 00042 00043 00044 /** register functions */ 00045 int stRegisterDestroyFunction(Stack *st, StDestroyFunction *destroyFunction); 00046 00047 #endif 00048
1.4.6