language-Modula2-0.1: examples/Modula-2_Libraries/C.-Lins_Modula-2_Software_Component_Library/Vol1/STACKS/STKSUUN.DEF
(*
7.3 StackSUUN Interface
An implementation of the stack abstraction, described in chapter 5, is presented here.
This particular form has the properties: Sequential, Unbounded, Unmanaged, and Non-Iterator.
These describe specific aspects of the implementation as follows:
Sequential: Can only be used in a non-tasking environment, or by only one task.
Unbounded: The size of a stack varies dynamically as items are added and removed.
Unmanaged: Memory space for objects is returned to the system when no
longer needed. Items are NOT managed.
Non-Iterator: Routines for looping over each of the stack items are not provided.
The interface to the unbounded stack is presented below.
Refer to StackSUMN for comments.
*)
DEFINITION MODULE StkSUUN;
(*============================================================
Version : 1.00 28 Apr 1989 C. Lins
Compiler : TopSpeed Modula-2
Component: Monolithic Structures - Stack (Opaque version)
Sequential Unbounded Unmanaged Non-Iterator
REVISION HISTORY
v1.00 28 Apr 1989 C. Lins:
Initial implementation
============================================================*)
FROM Items IMPORT
(*--Type*) Item;
FROM StackEnum IMPORT
(*--Type*) Exceptions;
FROM ErrorHandling IMPORT
(*--Type*) HandlerProc;
(*-----------------------*)
TYPE Stack;
CONST NullStack = Stack(NIL);
(*-----------------------*)
CONST ModuleID = 7;
PROCEDURE StackError () : Exceptions (*-- out *);
PROCEDURE GetHandler ( theError : Exceptions (*-- in *))
: HandlerProc (*-- out *);
PROCEDURE SetHandler ( theError : Exceptions (*-- in *);
theHandler : HandlerProc (*-- in *));
(*-----------------------*)
PROCEDURE Create () : Stack (*-- out *);
PROCEDURE Destroy (VAR theStack : Stack (*-- inout *));
PROCEDURE Clear (VAR theStack : Stack (*-- inout *));
PROCEDURE Assign ( theStack : Stack (*-- in *);
VAR toStack : Stack (*-- inout *));
PROCEDURE Push (VAR toStack : Stack (*-- inout *);
theItem : Item (*-- in *));
PROCEDURE Pop (VAR theStack : Stack (*-- inout *));
PROCEDURE PopTopOf (VAR theStack : Stack (*-- inout *))
: Item (*-- out *);
(*-----------------------*)
PROCEDURE IsDefined ( theStack : Stack (*-- in *))
: BOOLEAN (*-- out *);
PROCEDURE IsEmpty ( theStack : Stack (*-- in *))
: BOOLEAN (*-- out *);
PROCEDURE IsEqual ( left : Stack (*-- in *);
right : Stack (*-- in *))
: BOOLEAN (*-- out *);
PROCEDURE DepthOf ( theStack : Stack (*-- in *))
: CARDINAL (*-- out *);
PROCEDURE TopOf ( theStack : Stack (*-- in *))
: Item (*-- out *);
END StkSUUN.