1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
|
type statistics = Stdcompat__hashtbl_ext.statistics
= {
num_bindings : int;
num_buckets : int;
max_bucket_length : int;
bucket_histogram : int array;
}
type ('a, 'b) t = ('a, 'b) Hashtbl.t
let clear = Hashtbl.clear
let copy = Hashtbl.copy
let add = Hashtbl.add
let find = Hashtbl.find
let find_all = Hashtbl.find_all
let mem = Hashtbl.mem
let remove = Hashtbl.remove
let replace = Hashtbl.replace
let iter = Hashtbl.iter
let fold = Hashtbl.fold
module type HashedType = Hashtbl.HashedType
let hash = Hashtbl.hash
@BEGIN_FROM_4_07_0@
let to_seq = Hashtbl.to_seq
let to_seq_values = Hashtbl.to_seq_values
let to_seq_keys = Hashtbl.to_seq_keys
let replace_seq = Hashtbl.replace_seq
let add_seq = Hashtbl.add_seq
let of_seq = Hashtbl.of_seq
@END_FROM_4_07_0@
@BEGIN_BEFORE_4_07_0@
@BEGIN_WITH_MAGIC@
let to_seq = Stdcompat__hashtbl_ext.to_seq
let to_seq_keys = Stdcompat__hashtbl_ext.to_seq_keys
let to_seq_values = Stdcompat__hashtbl_ext.to_seq_values
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let to_seq tbl = Stdcompat__hashtbl_ext.to_seq Hashtbl.fold tbl
let to_seq_keys tbl = Stdcompat__hashtbl_ext.to_seq_keys Hashtbl.fold tbl
let to_seq_values tbl = Stdcompat__hashtbl_ext.to_seq_values Hashtbl.fold tbl
@END_WITHOUT_MAGIC@
let add_seq tbl g = Stdcompat__hashtbl_ext.add_seq Hashtbl.add tbl g
let replace_seq tbl g = Stdcompat__hashtbl_ext.add_seq Hashtbl.replace tbl g
let of_seq g =
Stdcompat__hashtbl_ext.of_seq ~create:Hashtbl.create ~replace:Hashtbl.replace g
@END_BEFORE_4_07_0@
@BEGIN_FROM_4_05_0@
let find_opt = Hashtbl.find_opt
@END_FROM_4_05_0@
@BEGIN_BEFORE_4_05_0@
let find_opt tbl key =
Stdcompat__tools.option_find (find tbl) key
@END_BEFORE_4_05_0@
@BEGIN_FROM_4_03_0@
let is_randomized = Hashtbl.is_randomized
let filter_map_inplace = Hashtbl.filter_map_inplace
@END_FROM_4_03_0@
@BEGIN_BEFORE_4_03_0@
let is_randomized () = false
@BEGIN_WITH_MAGIC@
let filter_map_inplace filter table =
Stdcompat__hashtbl_ext.filter_map_inplace filter table
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let filter_map_inplace filter table =
let dict = {
Stdcompat__hashtbl_ext.clear = clear;
Stdcompat__hashtbl_ext.fold = fold;
Stdcompat__hashtbl_ext.add = add;
Stdcompat__hashtbl_ext.remove = remove;
Stdcompat__hashtbl_ext.replace = replace;
} in
Stdcompat__hashtbl_ext.filter_map_inplace dict filter table
@END_WITHOUT_MAGIC@
@END_BEFORE_4_03_0@
@BEGIN_FROM_3_08_0@
let length = Hashtbl.length
@END_FROM_3_08_0@
@BEGIN_BEFORE_3_08_0@
@BEGIN_WITH_MAGIC@
let length (table : ('a, 'b) t) =
let table : ('a, 'b) Stdcompat__hashtbl_ext.internal = Obj.magic table in
table.Stdcompat__hashtbl_ext.size
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let length table =
fold (fun _ _ counter -> succ counter) table 0
@END_WITHOUT_MAGIC@
@END_BEFORE_3_08_0@
@BEGIN_FROM_4_00_0@
let create = Hashtbl.create
let reset = Hashtbl.clear
let randomize = Hashtbl.randomize
let hash_param = Hashtbl.hash_param
let seeded_hash = Hashtbl.seeded_hash
let seeded_hash_param = Hashtbl.seeded_hash_param
let stats = Hashtbl.stats
@END_FROM_4_00_0@
@BEGIN_BEFORE_4_00_0@
let create ?random n = Hashtbl.create n
let reset = clear
let randomize () = ()
@BEGIN_FROM_3_08_0@
external hash_param :
int -> int -> 'a -> int = "caml_hash_univ_param" "noalloc"
@END_FROM_3_08_0@
@BEGIN_BEFORE_3_08_0@
external hash_param :
int -> int -> 'a -> int = "hash_univ_param" "noalloc"
@END_BEFORE_3_08_0@
let seeded_hash seed x = Hashtbl.hash (seed, x)
let seeded_hash_param meaningful total seed x =
Hashtbl.hash_param meaningful total (seed, x)
@BEGIN_WITH_MAGIC@
let stats (h : ('a, 'b) t) =
Stdcompat__hashtbl_ext.stats h
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let stats h =
Stdcompat__hashtbl_ext.stats ~length h
@END_WITHOUT_MAGIC@
@END_BEFORE_4_00_0@
module type S = sig
type key
@BEGIN_FROM_4_12_0@
type !'a t
@END_FROM_4_12_0@
@BEGIN_BEFORE_4_12_0@
type 'a t
@END_BEFORE_4_12_0@
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq : 'a t -> (key * 'a) Stdcompat__seq.t
val to_seq_keys : 'a t -> key Stdcompat__seq.t
val to_seq_values : 'a t -> 'a Stdcompat__seq.t
val add_seq : 'a t -> (key * 'a) Stdcompat__seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdcompat__seq.t -> unit
val of_seq : (key * 'a) Stdcompat__seq.t -> 'a t
end
@BEGIN_FROM_4_07_0@
module Make = Hashtbl.Make
@END_FROM_4_07_0@
@BEGIN_BEFORE_4_07_0@
module Make (H : HashedType) = struct
include Hashtbl.Make (H)
@BEGIN_WITH_MAGIC@
let to_seq = Stdcompat__hashtbl_ext.to_seq
let to_seq_keys = Stdcompat__hashtbl_ext.to_seq_keys
let to_seq_values = Stdcompat__hashtbl_ext.to_seq_values
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let to_seq tbl = Stdcompat__hashtbl_ext.to_seq fold tbl
let to_seq_keys tbl = Stdcompat__hashtbl_ext.to_seq_keys fold tbl
let to_seq_values tbl = Stdcompat__hashtbl_ext.to_seq_values fold tbl
@END_WITHOUT_MAGIC@
let add_seq tbl g = Stdcompat__hashtbl_ext.add_seq add tbl g
let replace_seq tbl g = Stdcompat__hashtbl_ext.add_seq replace tbl g
let of_seq g = Stdcompat__hashtbl_ext.of_seq ~create ~replace g
@BEGIN_BEFORE_4_05_0@
let find_opt tbl key =
Stdcompat__tools.option_find (find tbl) key
@END_BEFORE_4_05_0@
@BEGIN_BEFORE_4_03_0@
@BEGIN_WITH_MAGIC@
let filter_map_inplace filter table =
Stdcompat__hashtbl_ext.filter_map_inplace filter table
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let filter_map_inplace filter table =
let dict = {
Stdcompat__hashtbl_ext.clear = clear;
Stdcompat__hashtbl_ext.fold = fold;
Stdcompat__hashtbl_ext.add = add;
Stdcompat__hashtbl_ext.remove = remove;
Stdcompat__hashtbl_ext.replace = replace;
} in
Stdcompat__hashtbl_ext.filter_map_inplace dict filter table
@END_WITHOUT_MAGIC@
@END_BEFORE_4_03_0@
@BEGIN_BEFORE_3_08_0@
@BEGIN_WITH_MAGIC@
let length (table : 'a t) =
let table : (key, 'a) Stdcompat__hashtbl_ext.internal = Obj.magic table in
table.Stdcompat__hashtbl_ext.size
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let length table =
fold (fun _ _ counter -> succ counter) table 0
@END_WITHOUT_MAGIC@
@END_BEFORE_3_08_0@
@BEGIN_BEFORE_4_00_0@
let create capacity = create capacity
let reset = clear
@BEGIN_WITH_MAGIC@
let stats (h : 'a t) =
Stdcompat__hashtbl_ext.stats h
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let stats h =
Stdcompat__hashtbl_ext.stats ~length h
@END_WITHOUT_MAGIC@
@END_BEFORE_4_00_0@
end
@END_BEFORE_4_07_0@
module type SeededHashedType = sig
type t
val equal : t -> t -> bool
val seeded_hash : int -> t -> int
end
module type SeededS = sig
type key
@BEGIN_FROM_4_12_0@
type !'a t
@END_FROM_4_12_0@
@BEGIN_BEFORE_4_12_0@
type 'a t
@END_BEFORE_4_12_0@
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq : 'a t -> (key * 'a) Stdcompat__seq.t
val to_seq_keys : 'a t -> key Stdcompat__seq.t
val to_seq_values : 'a t -> 'a Stdcompat__seq.t
val add_seq : 'a t -> (key * 'a) Stdcompat__seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdcompat__seq.t -> unit
val of_seq : (key * 'a) Stdcompat__seq.t -> 'a t
end
@BEGIN_FROM_5_0_0@
module MakeSeeded = Hashtbl.MakeSeeded
@END_FROM_5_0_0@
@BEGIN_BEFORE_5_0_0@
module MakeSeeded (H : SeededHashedType) = struct
include Stdcompat__hashtbl_ext.MakeSeeded (H)
@BEGIN_WITH_MAGIC@
let to_seq = Stdcompat__hashtbl_ext.to_seq
let to_seq_keys = Stdcompat__hashtbl_ext.to_seq_keys
let to_seq_values = Stdcompat__hashtbl_ext.to_seq_values
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let to_seq tbl = Stdcompat__hashtbl_ext.to_seq fold tbl
let to_seq_keys tbl = Stdcompat__hashtbl_ext.to_seq_keys fold tbl
let to_seq_values tbl = Stdcompat__hashtbl_ext.to_seq_values fold tbl
@END_WITHOUT_MAGIC@
let add_seq tbl g = Stdcompat__hashtbl_ext.add_seq add tbl g
let replace_seq tbl g = Stdcompat__hashtbl_ext.add_seq replace tbl g
let of_seq g = Stdcompat__hashtbl_ext.of_seq ~create ~replace g
@BEGIN_BEFORE_4_05_0@
let find_opt tbl key =
Stdcompat__tools.option_find (find tbl) key
@END_BEFORE_4_05_0@
@BEGIN_BEFORE_4_03_0@
@BEGIN_WITH_MAGIC@
let filter_map_inplace filter table =
Stdcompat__hashtbl_ext.filter_map_inplace filter table
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let filter_map_inplace filter table =
let dict = {
Stdcompat__hashtbl_ext.clear = clear;
Stdcompat__hashtbl_ext.fold = fold;
Stdcompat__hashtbl_ext.add = add;
Stdcompat__hashtbl_ext.remove = remove;
Stdcompat__hashtbl_ext.replace = replace;
} in
Stdcompat__hashtbl_ext.filter_map_inplace dict filter table
@END_WITHOUT_MAGIC@
@END_BEFORE_4_03_0@
@BEGIN_BEFORE_3_08_0@
@BEGIN_WITH_MAGIC@
let length (table : 'a t) =
let table : (key, 'a) Stdcompat__hashtbl_ext.internal = Obj.magic table in
table.Stdcompat__hashtbl_ext.size
@END_WITH_MAGIC@
@BEGIN_WITHOUT_MAGIC@
let length table =
fold (fun _ _ counter -> succ counter) table 0
@END_WITHOUT_MAGIC@
@END_BEFORE_3_08_0@
@BEGIN_BEFORE_4_00_0@
let create ?random capacity = create capacity
let reset = clear
let stats tbl = {
num_bindings = length tbl;
num_buckets = 0;
max_bucket_length = 0;
bucket_histogram = [| |];
}
@END_BEFORE_4_00_0@
end
@END_BEFORE_5_0_0@
@BEGIN_FROM_4_12_0@
let rebuild = Hashtbl.rebuild
@END_FROM_4_12_0@
@BEGIN_BEFORE_4_12_0@
let rebuild ?random tbl =
let result = create ?random (stats tbl).num_buckets in
iter (add result) tbl;
result
@END_BEFORE_4_12_0@
|