home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / EDSV4064.ZIP / EPP-V1_1.ZIP / STACK.E < prev    next >
Text File  |  1993-06-26  |  834b  |  38 lines

  1. OPT TURBO
  2.  
  3. OBJECT st_stackType
  4.   top, count
  5. ENDOBJECT
  6.  
  7. PROC st_init (theStack : PTR TO st_stackType)
  8. /* Simply declare the stack variable as st_stackType.   The status of the */
  9. /* stack can be checked by testing stackname.count.                       */
  10.   theStack.top := NIL
  11.   theStack.count := 0
  12. ENDPROC
  13.   /* st_init */
  14.  
  15.  
  16. PROC st_push (theStack : PTR TO st_stackType, addr)
  17.   DEF newList, tempList
  18.   newList := List (1)
  19.   ListCopy (newList, [addr], ALL)
  20.   tempList := Link (newList, theStack.top)
  21.   theStack.top := tempList
  22.   theStack.count := theStack.count + 1
  23. ENDPROC
  24.   /* st_push */
  25.  
  26.  
  27. PROC st_pop (theStack : PTR TO st_stackType)
  28.   DEF list, addr = NIL
  29.   IF theStack.count
  30.     list := theStack.top
  31.     addr := ^list
  32.     theStack.top := Next (list)
  33.     theStack.count := theStack.count - 1
  34.   ENDIF
  35. ENDPROC  addr
  36.   /* st_pop */
  37.  
  38.