module Stack:imperative stacksig
..end
exception OVERFLOW
type 'a
stack
val create : 'a -> 'a stack
create null_element
creates an empty stack.
null element must be provided.val clear : 'a stack -> unit
val is_empty : 'a stack -> bool
val size : 'a stack -> int
val push : 'a stack -> 'a -> unit
OVERFLOW
if the stack is full.val top : 'a stack -> 'a
Not_found
if the stack is empty.val pop : 'a stack -> 'a
Not_found
if the stack is empty.val remove_top : 'a stack -> unit
Not_found
if the stack is empty.val iter : ('a -> unit) -> 'a stack -> unit
val fold : ('a -> 'b -> 'a) -> 'a -> 'b stack -> 'a
val iter_stop : ('a -> unit) -> ('a -> bool) -> 'a stack -> unit
iter_stop apply stop
like iter
,
but stop the traversal if stop
is true on a stack element.
stop is checked before apply.val map : ('a -> 'a) -> 'a stack -> 'a stack
val sort : ('a -> 'a -> int) -> 'a stack -> unit
val find : 'a stack -> ('a -> int) -> 'a
find stack check
finds the element specified by check
.
stack
must be sorted according to an ordering.
check
delivers the result of this ordering
for the search for element and any stack element.
it returns 0, if the stack element is equal to the searchecd element,
-1, if the stack element is greater,
+1 otherwise.