1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset= ISO-8859-1">
<TITLE>
Module Stack: last-in first-out stacks
</TITLE>
</HEAD>
<BODY >
<A HREF="manual054.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual056.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>
<H2>17.25 Module <TT>Stack</TT>: last-in first-out stacks</H2><A NAME="s:Stack"></A>
<A NAME="@manual438"></A><BLOCKQUOTE>
This module implements stacks (LIFOs), with in-place modification.
</BLOCKQUOTE>
<PRE>
type 'a t
</PRE>
<BLOCKQUOTE>
The type of stacks containing elements of type <CODE>'a</CODE>.
</BLOCKQUOTE>
<PRE>
exception Empty
</PRE>
<A NAME="@manual439"></A><BLOCKQUOTE>
Raised when <CODE>pop</CODE> is applied to an empty stack.
</BLOCKQUOTE>
<PRE>
val create: unit -> 'a t
</PRE>
<A NAME="@manual440"></A><BLOCKQUOTE>
Return a new stack, initially empty.
</BLOCKQUOTE>
<PRE>
val push: 'a -> 'a t -> unit
</PRE>
<A NAME="@manual441"></A><BLOCKQUOTE>
<CODE>push x s</CODE> adds the element <CODE>x</CODE> at the top of stack <CODE>s</CODE>.
</BLOCKQUOTE>
<PRE>
val pop: 'a t -> 'a
</PRE>
<A NAME="@manual442"></A><BLOCKQUOTE>
<CODE>pop s</CODE> removes and returns the topmost element in stack <CODE>s</CODE>,
or raises <CODE>Empty</CODE> if the stack is empty.
</BLOCKQUOTE>
<PRE>
val clear : 'a t -> unit
</PRE>
<A NAME="@manual443"></A><BLOCKQUOTE>
Discard all elements from a stack.
</BLOCKQUOTE>
<PRE>
val length: 'a t -> int
</PRE>
<A NAME="@manual444"></A><BLOCKQUOTE>
Return the number of elements in a stack.
</BLOCKQUOTE>
<PRE>
val iter: ('a -> unit) -> 'a t -> unit
</PRE>
<A NAME="@manual445"></A><BLOCKQUOTE>
<CODE>iter f s</CODE> applies <CODE>f</CODE> in turn to all elements of <CODE>s</CODE>,
from the element at the top of the stack to the element at the
bottom of the stack. The stack itself is unchanged.
</BLOCKQUOTE>
<HR>
<A HREF="manual054.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual056.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>
|