Module CCHash
Hash combinators
The API of this module is stable as per semantic versioning, like the rest of containers. However the exact implementation of hashing function can change and should not be relied on (i.e. hashing a value always returns the same integer within a run of a program, not across versions of OCaml and Containers).
Definitions
type 'a t= 'a -> hashA hash function for values of type
'a.
val const0 : _ tAlways return 0. Useful for ignoring elements. Example:
Hash.(pair string const0)will map pairs("a", 1)and("a", 2)to the same hash, but not the same as("b", 1).- since
- 1.5
val int : int tval bool : bool tval char : char tval int32 : int32 tval int64 : int64 tval nativeint : nativeint tval slice : string -> int -> int tslice s i len statehashes the slicei, …, i+len-1ofsintostate.
val bytes : bytes tHash a byte array.
- since
- 3.5
val string : string tval list : 'a t -> 'a list tval array : 'a t -> 'a array tval opt : 'a t -> 'a option tval pair : 'a t -> 'b t -> ('a * 'b) tval triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) tval quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) tval map : ('a -> 'b) -> 'b t -> 'a tmap f his the hasher that takesx, and useshto hashf x.For example:
module Str_set = Set.Make(String) let hash_str_set : Str_set.t CCHash.t = CCHash.(map Str_set.to_seq @@ seq string)- since
- 3.5
val poly : 'a tpoly xisHashtbl.hash x. The regular polymorphic hash function.