/*--------------------------------------------------------------------*/ /* stack.h (Version 2) */ /* Author: Bob Dondero */ /*--------------------------------------------------------------------*/ #ifndef STACK_INCLUDED #define STACK_INCLUDED struct Stack; /* A struct Stack is a last-in-first-out collection of doubles. */ struct Stack *Stack_new(void); /* Return a new Stack. */ void Stack_free(struct Stack *psStack); /* Free psStack. Do nothing if psStack is NULL. */ 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_top(struct Stack *psStack); /* Return the top item of *psStack. It is a checked runtime error for psStack to be NULL or for *psStack to be empty. */ void Stack_pop(struct Stack *psStack); /* Pop *psStack, and discard 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