Head file for stack.c. It implements a data structure stack. The size of this stack is STACKSIZE, the type of each element in the stack is element. Change the typedef of this element and recompile, then you have a stack of another type.
  • push an element into the stack, if it is not full yet.
  • pop an element out of the stack, if it is not empty (or pops out a zero).
  • duplicate the top element of the stack, if it is not empty (or a zero is returned).
  • up the stack by one element in the cyclic style.
  • down the stack by one element in the cyclic style.
  • list the stack elements, from top to bottom, to the stdout.
  • swaptop swaps the topest two elements in the stack, if there are enough of them.

  • #define STACKSIZE 100
    
    typedef double element;
    
    void push(element);
    element pop(void);
    element dup(void);
    void up(void);
    void down(void);
    void list(void);
    void swaptop(void);
    

    Created: Nov 26, 1994
    Last Revised: Dec 6, 1994
    © Copyright 1994 Wei-Chang Shann

    shann@math.ncu.edu.tw