#include "c:stack.h" /* initializes stack by setting top to 0 */ void CreateStack(STACK_TYPE *stack) { stack->top=0; } /* resets stack by resetting top to 0 */ void DestroyStack(STACK_TYPE *stack) { stack->top=0; } /* checks if stack is empty (if top is 0) */ BOOLEAN EmptyStack(STACK_TYPE *stack) { if (stack->top==0) return TRUE; else return FALSE; } /* checks if stack is full (if top is MAX_STACK) */ BOOLEAN FullStack(STACK_TYPE *stack) { if (stack->top == MAX) return TRUE; else return FALSE; } /* put item at position top and then increment top */ void Push(STACK_TYPE *stack, ITEM_TYPE newitem) { stack->item[stack->top]=newitem; stack->top++; } /* decrement top by 1 and then copy the item at top */ void Pop(STACK_TYPE *stack, ITEM_TYPE *old_item) { stack->top--; *old_item=stack->item[stack->top]; }