summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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. *)