/********************************************************************************** * Stack.h * Header file for Stack ADT ***********************************************************************************/ #if !defined(_STACK_H_INCLUDE_) #define _STACK_H_INCLUDE_ /***************************** Exported Types *************************************/ typedef struct Stack * StackRef; /************** Constructors-Destructors ******************************************/ /* * newStack * Returns StackRef pointing to new StackSturct which represents an empty Stack. * Initializes top field to NULL, sets height field to 0. Exported. */ StackRef newStack(void); /* * freeStack * Frees all heap memory associated with the StackRef *pS, including all memory * in existing Nodes. Sets *pS to NULL. Exported. */ void freeStack(StackRef* pS); /***************** Access functions ***********************************************/ /* * getTop * Returns the value at the top of S. * Pre: !isEmpty(S) */ int getTop(StackRef S); /* * getHeight * Returns the height of S */ int getHeight(StackRef S); /* * isEmpty * Returns True if S is empty, otherwise returns false */ int isEmpty(StackRef S); /****************************** Manipulation procedures ***************************/ /* * push * Places new data element on top of S * Post: !isEmpty(S) */ void push(StackRef S, int data); /* * pop * Deletes element on top of S * Pre: !isEmpty(S) */ void pop(StackRef S); /*************** Other Functions *************************************************/ /* * printStack * Prints data elements in S on a single line to stdout. */ void printStack(StackRef S); /* * equals * returns true if Stack A is identical to Stack B, false otherwise */ int equals(StackRef A, StackRef B); #endif