/*------------------------------------------------------------------*/ /* stackbad.h (A Stack ADT Interface) */ /* Author: Bob Dondero */ /* A Stack ADT interface that reveals the data structure to clients */ /*------------------------------------------------------------------*/ #ifndef STACKBAD_INCLUDED #define STACKBAD_INCLUDED /* A Stack is a last-in-first-out collection of doubles. */ struct Stack { /* The array in which items are stored. */ double *pdArray; /* The index one beyond the top element. */ int iTop; /* The number of elements in the array. */ int iPhysLength; }; struct Stack *Stack_new(void); /* Return the address of a new Stack. */ void Stack_free(struct Stack *psStack); /* Free psStack. */ void Stack_push(struct Stack *psStack, double dItem); /* Push dItem onto *psStack. It is a checked runtime error for psStack to be NULL. */ double Stack_pop(struct Stack *psStack); /* Pop *psStack, and return the popped item. It is a checked runtime error for psStack to be NULL or for *psStack to be empty. */ int Stack_isEmpty(struct Stack *psStack); /* Return 1 (TRUE) iff *psStack is empty. It is a checked runtime error for psStack to be NULL. */ #endif