summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2002-06-27 08:48:26 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2002-06-27 08:48:26 +0000
commit26fb2b92acf70e43f71baa77d1c0d595ab71b143 (patch)
tree18f0271782d148b07fcda405a8e48e807763d7df /stdlib
parent4a5afb7ff30426a552e7193f768c06ad33306300 (diff)
Ajout operation is_empty
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4956 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/queue.ml3
-rw-r--r--stdlib/queue.mli3
-rw-r--r--stdlib/stack.ml2
-rw-r--r--stdlib/stack.mli3
4 files changed, 11 insertions, 0 deletions
diff --git a/stdlib/queue.ml b/stdlib/queue.ml
index 477afcb08..5a08721f5 100644
--- a/stdlib/queue.ml
+++ b/stdlib/queue.ml
@@ -123,6 +123,9 @@ let copy q =
tail = tail'
}
+let is_empty q =
+ q.length = 0
+
let length q =
q.length
diff --git a/stdlib/queue.mli b/stdlib/queue.mli
index bd9879041..085cfb003 100644
--- a/stdlib/queue.mli
+++ b/stdlib/queue.mli
@@ -55,6 +55,9 @@ val clear : 'a t -> unit
val copy : 'a t -> 'a t
(** Return a copy of the given queue. *)
+val is_empty : 'a t -> bool
+(** Return [true] if the given queue is empty, [false] otherwise. *)
+
val length : 'a t -> int
(** Return the number of elements in a queue. *)
diff --git a/stdlib/stack.ml b/stdlib/stack.ml
index f49ed547f..03277d079 100644
--- a/stdlib/stack.ml
+++ b/stdlib/stack.ml
@@ -35,6 +35,8 @@ let top s =
hd::_ -> hd
| [] -> raise Empty
+let is_empty s = (s.c = [])
+
let length s = List.length s.c
let iter f s = List.iter f s.c
diff --git a/stdlib/stack.mli b/stdlib/stack.mli
index 536dd5553..50a46ed04 100644
--- a/stdlib/stack.mli
+++ b/stdlib/stack.mli
@@ -45,6 +45,9 @@ val clear : 'a t -> unit
val copy : 'a t -> 'a t
(** Return a copy of the given stack. *)
+val is_empty : 'a t -> bool
+(** Return [true] if the given stack is empty, [false] otherwise. *)
+
val length : 'a t -> int
(** Return the number of elements in a stack. *)