add mem to CCHashTrie

This commit is contained in:
Simon Cruanes 2015-09-05 01:52:55 +02:00
parent 791eb8efba
commit 47414c7f40
2 changed files with 12 additions and 4 deletions

View file

@ -38,6 +38,8 @@ module type S = sig
val add : key -> 'a -> 'a t -> 'a t
val mem : key -> _ t -> bool
val get : key -> 'a t -> 'a option
val get_exn : key -> 'a t -> 'a
@ -317,6 +319,10 @@ module Make(Key : KEY)
try Some (get_exn_ k ~h:(hash_ k) m)
with Not_found -> None
let mem k m =
try ignore (get_exn_ k ~h:(hash_ k) m); true
with Not_found -> false
(* TODO: use Hash.combine if array only has one non-empty LEAF element? *)
(* [left] list nodes already visited *)

View file

@ -47,6 +47,8 @@ module type S = sig
val add : key -> 'a -> 'a t -> 'a t
val mem : key -> _ t -> bool
val get : key -> 'a t -> 'a option
val get_exn : key -> 'a t -> 'a