aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cArray.ml3
-rw-r--r--lib/cArray.mli3
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/cArray.ml b/lib/cArray.ml
index 7ffdeb6a1..05c8cc87c 100644
--- a/lib/cArray.ml
+++ b/lib/cArray.ml
@@ -41,6 +41,7 @@ sig
include S
val compare : ('a -> 'a -> int) -> 'a array -> 'a array -> int
val equal : ('a -> 'a -> bool) -> 'a array -> 'a array -> bool
+ val is_empty : 'a array -> bool
val exists : ('a -> bool) -> 'a array -> bool
val for_all : ('a -> bool) -> 'a array -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
@@ -108,6 +109,8 @@ let equal cmp t1 t2 =
(i = Array.length t1) || (cmp t1.(i) t2.(i) && aux (i + 1))
in aux 0
+let is_empty array = (Array.length array) = 0
+
let exists f v =
let rec exrec = function
| -1 -> false
diff --git a/lib/cArray.mli b/lib/cArray.mli
index ed8a1e94c..0e0be1dfd 100644
--- a/lib/cArray.mli
+++ b/lib/cArray.mli
@@ -47,6 +47,9 @@ sig
val equal : ('a -> 'a -> bool) -> 'a array -> 'a array -> bool
(** Lift equality to array type. *)
+ val is_empty : 'a array -> bool
+ (** True whenever the array is empty. *)
+
val exists : ('a -> bool) -> 'a array -> bool
(** As [List.exists] but on arrays. *)