@@ -4981,6 +4981,14 @@ module type S = sig
4981
4981
val find_exn: 'a t -> key -> 'a
4982
4982
val find_all: 'a t -> key -> 'a list
4983
4983
val find_opt: 'a t -> key -> 'a option
4984
+
4985
+ (** return the key found in the hashtbl.
4986
+ Use case: when you find the key existed in hashtbl,
4987
+ you want to use the one stored in the hashtbl.
4988
+ (they are semantically equivlanent, but may have other information different)
4989
+ *)
4990
+ val find_key_opt: 'a t -> key -> key option
4991
+
4984
4992
val find_default: 'a t -> key -> 'a -> 'a
4985
4993
4986
4994
val replace: 'a t -> key -> 'a -> unit
@@ -5124,6 +5132,23 @@ let rec small_bucket_opt eq key (lst : _ bucketlist) : _ option =
5124
5132
if eq key k3 then Some d3 else
5125
5133
small_bucket_opt eq key rest3
5126
5134
5135
+
5136
+ let rec small_bucket_key_opt eq key (lst : _ bucketlist) : _ option =
5137
+ match lst with
5138
+ | Empty -> None
5139
+ | Cons(k1,d1,rest1) ->
5140
+ if eq key k1 then Some k1 else
5141
+ match rest1 with
5142
+ | Empty -> None
5143
+ | Cons(k2,d2,rest2) ->
5144
+ if eq key k2 then Some k2 else
5145
+ match rest2 with
5146
+ | Empty -> None
5147
+ | Cons(k3,d3,rest3) ->
5148
+ if eq key k3 then Some k3 else
5149
+ small_bucket_key_opt eq key rest3
5150
+
5151
+
5127
5152
let rec small_bucket_default eq key default (lst : _ bucketlist) =
5128
5153
match lst with
5129
5154
| Empty -> default
@@ -5258,6 +5283,10 @@ let find_exn (h : _ t) key =
5258
5283
5259
5284
let find_opt (h : _ t) key =
5260
5285
Hashtbl_gen.small_bucket_opt eq_key key (Array.unsafe_get h.data (key_index h key))
5286
+
5287
+ let find_key_opt (h : _ t) key =
5288
+ Hashtbl_gen.small_bucket_key_opt eq_key key (Array.unsafe_get h.data (key_index h key))
5289
+
5261
5290
let find_default (h : _ t) key default =
5262
5291
Hashtbl_gen.small_bucket_default eq_key key default (Array.unsafe_get h.data (key_index h key))
5263
5292
let find_all (h : _ t) key =
0 commit comments