From b09f3774a4c1033050b456a759a1b3c8e34dd1d7 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 16 Apr 2020 03:37:45 -0700 Subject: [PATCH] [sledge] Add Qset.is_empty Reviewed By: jvillard Differential Revision: D20663962 fbshipit-source-id: a0d23d4fc --- sledge/lib/import/qset.ml | 1 + sledge/lib/import/qset_intf.ml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/sledge/lib/import/qset.ml b/sledge/lib/import/qset.ml index 11772e6a5..ba73cd028 100644 --- a/sledge/lib/import/qset.ml +++ b/sledge/lib/import/qset.ml @@ -71,6 +71,7 @@ struct M.fold m' ~init:m ~f:(fun ~key:x ~data:i m -> add m x i) let map_counts m ~f = M.mapi ~f:(fun ~key ~data -> f key data) m + let is_empty = M.is_empty let length m = M.length m let count m x = match M.find m x with Some q -> q | None -> Q.zero let choose = M.choose diff --git a/sledge/lib/import/qset_intf.ml b/sledge/lib/import/qset_intf.ml index 8c01787ad..f0c1d5fae 100644 --- a/sledge/lib/import/qset_intf.ml +++ b/sledge/lib/import/qset_intf.ml @@ -43,6 +43,8 @@ module type S = sig (* queries *) + val is_empty : t -> bool + val length : t -> int (** Number of elements with non-zero multiplicity. [O(1)]. *)