diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2001-10-25 11:32:25 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2001-10-25 11:32:25 +0000 |
commit | 3868cc561ea9a7d63ab6af04b5847864e0bf0068 (patch) | |
tree | f3d05024feba34a07c45421bb1b187d4316a48c1 /stdlib | |
parent | 09fe95f22e3b569e61401fb29774f0a1ff58106a (diff) |
Ajout Stack.copy
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3918 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/stack.ml | 2 | ||||
-rw-r--r-- | stdlib/stack.mli | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/stdlib/stack.ml b/stdlib/stack.ml index bcc616f79..c6c526fde 100644 --- a/stdlib/stack.ml +++ b/stdlib/stack.ml @@ -20,6 +20,8 @@ let create () = { c = [] } let clear s = s.c <- [] +let copy s = { c = s.c } + let push x s = s.c <- x :: s.c let pop s = diff --git a/stdlib/stack.mli b/stdlib/stack.mli index ccb40797d..adff73f57 100644 --- a/stdlib/stack.mli +++ b/stdlib/stack.mli @@ -34,6 +34,8 @@ val top: 'a t -> 'a or raises [Empty] if the stack is empty. *) val clear: 'a t -> unit (* Discard all elements from a stack. *) +val copy: 'a t -> 'a t + (* Return a copy of the given stack. *) val length: 'a t -> int (* Return the number of elements in a stack. *) val iter: ('a -> unit) -> 'a t -> unit |