home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / compiler / Stack.sig < prev    next >
Encoding:
Text File  |  1997-08-18  |  982 b   |  27 lines  |  [TEXT/R*ch]

  1. (* Stack.sig *)
  2.  
  3. (* This module implements stacks (LIFOs), with in-place modification. *)
  4.  
  5. type 'a t;
  6.         (* The type of stacks containing elements of type ['a]. *)
  7.  
  8. exception Empty;
  9.         (* Raised when [pop] is applied to an empty stack. *)
  10.  
  11. val new: unit -> '_a t;
  12.       (* Return a new stack, initially empty. *)
  13. val push: 'a -> 'a t -> unit;
  14.       (* [push x s] adds the element [x] at the top of stack [s]. *)
  15. val pop: 'a t -> 'a;
  16.       (* [pop s] removes and returns the topmost element in stack [s],
  17.          or raises [Empty] if the stack is empty. *)
  18. val peek: 'a t -> 'a;
  19.       (* [pop s] returns the topmost element in stack [s],
  20.          without removing it, or raises [Empty] if the stack is empty. *)
  21. val update: 'a -> 'a t -> unit;
  22.       (* [update x s] replaces the top element of stack [s] with [x]. *)
  23. val null: 'a t -> bool;
  24.       (* [null s] returns true iff stack [s] is empty. *)
  25. val clear : 'a t -> unit;
  26.       (* Discard all elements from a stack. *)
  27.