Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #ifndef STACK_STACK_H
  2. #define STACK_STACK_H
  3. #define StackEntry int
  4. #include <iostream>
  5.  
  6. typedef struct StackNode
  7. {
  8. StackEntry entry;
  9. StackNode* next;
  10. }StackNode;
  11.  
  12. typedef struct stack
  13. {
  14. StackNode* top;
  15. int size;
  16. }Stack;
  17.  
  18. //pre-conditions: stack is initialized and not full(the user must check that the stack is not full)
  19. void push(StackEntry pe,Stack *ps);
  20. //post-conditions: the element is stored on top and not changed
  21.  
  22. //pre-conditions: stack is initialized and not empty(the user must check that the stack is not empty)
  23. void pop(StackEntry *pe,Stack *ps);
  24. //post-conditions: the top value is cleared from the stack and its value is returned
  25.  
  26. void CreateStack(Stack *ps);
  27.  
  28. int StackFull(Stack *ps);
  29.  
  30. int StackEmpty(Stack *ps);
  31.  
  32. void Traverse(Stack *ps,void(*pf)(StackEntry));
  33.  
  34. void ClearStack(Stack *ps);
  35.  
  36. int StackSize(Stack *ps);
  37.  
  38. void StackTop(StackEntry *pe,Stack *ps);
  39. #endif //STACK_STACK_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement