home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 001-010 / amok07 / stack / stack.def < prev    next >
Encoding:
Modula Definition  |  1993-11-04  |  1.7 KB  |  54 lines

  1. (*********************************************************************
  2.  *
  3.  *  :Program.    Stack.def
  4.  *  :Author.     Michael Frieß
  5.  *  :Address.    Kernerstr. 22a
  6.  *  :shortcut.   [MiF]
  7.  *  :Version.    1.0
  8.  *  :Date.       15.09.88
  9.  *  :Copyright.  PD
  10.  *  :Language.   Modula-II
  11.  *  :Translator. M2Amiga
  12.  *  :Imports.    MemSystem (at least V1.0 --> Amok#5)
  13.  *  :Contents.   Generic data type: Stack
  14.  *
  15.  *********************************************************************)
  16.  
  17. DEFINITION MODULE Stack;
  18.  
  19. FROM SYSTEM   IMPORT BYTE, ADDRESS;
  20.  
  21. TYPE stack; (* opaque type! *)
  22.      (* stack is a simple LIFO-list (Last-In-First-Out) *)
  23.  
  24. PROCEDURE Init (VAR s:stack);
  25.   (* :output.s = use this variable, when you call stack-procedures
  26.      :semantic.Initialize stack s for further use                   *)
  27.  
  28.  
  29. PROCEDURE Write (VAR s:stack; Data : ARRAY OF BYTE);
  30.   (* :input.s    = data is to be written in this stack
  31.      :input.data = data to be written
  32.      :semantic.a new element is appended at top of stack s
  33.      :semantic.containing the given data.                           *)
  34.  
  35. PROCEDURE Read (VAR s:stack; VAR Data : ARRAY OF BYTE);
  36.   (* :input. s    = read of this stack
  37.      :output.Data = contents of top element in stack
  38.      :semantic.The contents of the top element is read into Data
  39.      :semantic.and top element is removed from stack.               *)
  40.  
  41. PROCEDURE Empty (s:stack) : BOOLEAN;
  42.   (* :input.s = stack
  43.      :return.TRUE  : stack is empty
  44.      :return.FALSE : otherwise
  45.      :semantic.returns, whether stack is empty or not.              *)
  46.  
  47.  
  48. PROCEDURE Discard (VAR s:stack);
  49.   (* :input.s = stack
  50.      :semantic.Memory allocated for stack s is given back to
  51.      :semantic.operating system.                                    *)
  52.  
  53. END Stack.
  54.