mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-09 20:55:31 -05:00
feat(intmap): add is_empty function
This commit is contained in:
parent
aa4b2a4680
commit
7f1c6ae66f
2 changed files with 20 additions and 6 deletions
|
|
@ -73,20 +73,30 @@ end
|
|||
(Bit.highest x :> int) (highest2 x))
|
||||
*)
|
||||
|
||||
type 'a t =
|
||||
(*$inject
|
||||
let _list_uniq l = CCList.sort_uniq ~cmp:(fun a b-> Pervasives.compare (fst a)(fst b)) l
|
||||
*)
|
||||
|
||||
type +'a t =
|
||||
| E (* empty *)
|
||||
| L of int * 'a (* leaf *)
|
||||
| N of int (* common prefix *) * Bit.t (* bit switch *) * 'a t * 'a t
|
||||
|
||||
let empty = E
|
||||
|
||||
let is_empty = function
|
||||
| E -> true
|
||||
| _ -> false
|
||||
|
||||
(*$Q
|
||||
Q.(small_list (pair int int)) (fun l -> \
|
||||
let m = of_list l in \
|
||||
is_empty m = (cardinal m = 0))
|
||||
*)
|
||||
|
||||
let is_prefix_ ~prefix y ~bit =
|
||||
prefix = Bit.mask y ~mask:bit
|
||||
|
||||
(*$inject
|
||||
let _list_uniq l = CCList.sort_uniq ~cmp:(fun a b-> Pervasives.compare (fst a)(fst b)) l
|
||||
*)
|
||||
|
||||
(*$Q
|
||||
Q.int (fun i -> \
|
||||
let b = Bit.highest i in \
|
||||
|
|
|
|||
|
|
@ -6,10 +6,14 @@
|
|||
{b status: stable}
|
||||
@since 0.10 *)
|
||||
|
||||
type 'a t
|
||||
type +'a t
|
||||
|
||||
val empty : 'a t
|
||||
|
||||
val is_empty : _ t -> bool
|
||||
(** Is the map empty?
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val singleton : int -> 'a -> 'a t
|
||||
|
||||
val doubleton : int -> 'a -> int -> 'a -> 'a t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue