Skip to content
This repository
tag: v1727
Fetching contributors…

Cannot retrieve contributors at this time

file 73 lines (61 sloc) 2.345 kb
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
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(**
the original module from the stdlib
*)
type ('a, 'b) t = ('a,'b) Hashtbl.t
val create : int -> ('a, 'b) t
val clear : ('a, 'b) t -> unit
val add : ('a, 'b) t -> 'a -> 'b -> unit
val copy : ('a, 'b) t -> ('a, 'b) t
val find : ('a, 'b) t -> 'a -> 'b
val find_all : ('a, 'b) t -> 'a -> 'b list
val mem : ('a, 'b) t -> 'a -> bool
val remove : ('a, 'b) t -> 'a -> unit
val replace : ('a, 'b) t -> 'a -> 'b -> unit
val iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit
val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c
val length : ('a, 'b) t -> int

module type HashedType = Hashtbl.HashedType
module type S = sig
  include Hashtbl.S
  val replace_content :'a t -> 'a t -> unit
  val find_opt : 'a t -> key -> 'a option
end
module Make (H : HashedType) : S with type key = H.t

val hash : 'a -> int
external hash_param : int -> int -> 'a -> int = "caml_hash_univ_param" "noalloc"

(**
additional functions
*)

val find_opt : ('a,'b) Hashtbl.t -> 'a -> 'b option

val replace_content : ('a,'b) Hashtbl.t -> ('a,'b) Hashtbl.t -> unit
  (**
[replace_content h1 h2] behaves as [h1 <- h2] if this operation was possible
It is unspecified whether modifying the [h2] affects [h1].
If you want the hashtbl to "diverge", use [replace_content h1 (copy h2)].
If you want the hashtbl to share their changes, well, too bad for you,
that's not possible. Use references over your hashtbl instead.
*)

(**
Magic combinator for hashes.
Stolen from ocaml sources
*)
val combine : int -> int -> int

(** {6 Extension} *)

(**
Pick an unspecified element of a [Hashtbl], and remove it.
Nothing happens if the table is empty.
*)
val pick_remove : ('a, 'b) t -> unit
Something went wrong with that request. Please try again.