home *** CD-ROM | disk | FTP | other *** search
Modula Definition | 1993-11-04 | 1.7 KB | 54 lines |
- (*********************************************************************
- *
- * :Program. Stack.def
- * :Author. Michael Frieß
- * :Address. Kernerstr. 22a
- * :shortcut. [MiF]
- * :Version. 1.0
- * :Date. 15.09.88
- * :Copyright. PD
- * :Language. Modula-II
- * :Translator. M2Amiga
- * :Imports. MemSystem (at least V1.0 --> Amok#5)
- * :Contents. Generic data type: Stack
- *
- *********************************************************************)
-
- DEFINITION MODULE Stack;
-
- FROM SYSTEM IMPORT BYTE, ADDRESS;
-
- TYPE stack; (* opaque type! *)
- (* stack is a simple LIFO-list (Last-In-First-Out) *)
-
- PROCEDURE Init (VAR s:stack);
- (* :output.s = use this variable, when you call stack-procedures
- :semantic.Initialize stack s for further use *)
-
-
- PROCEDURE Write (VAR s:stack; Data : ARRAY OF BYTE);
- (* :input.s = data is to be written in this stack
- :input.data = data to be written
- :semantic.a new element is appended at top of stack s
- :semantic.containing the given data. *)
-
- PROCEDURE Read (VAR s:stack; VAR Data : ARRAY OF BYTE);
- (* :input. s = read of this stack
- :output.Data = contents of top element in stack
- :semantic.The contents of the top element is read into Data
- :semantic.and top element is removed from stack. *)
-
- PROCEDURE Empty (s:stack) : BOOLEAN;
- (* :input.s = stack
- :return.TRUE : stack is empty
- :return.FALSE : otherwise
- :semantic.returns, whether stack is empty or not. *)
-
-
- PROCEDURE Discard (VAR s:stack);
- (* :input.s = stack
- :semantic.Memory allocated for stack s is given back to
- :semantic.operating system. *)
-
- END Stack.
-