package containers
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=1e7992cb2e59c0d2290d1b6c3a31531b3f310be6170b8ef3dde17ccd876b5b79
sha512=bb124e69ad0690f88393e18eee499be07761e767593558867aab32f643466b43258ced503170b154ca3b56dbd68987abd6d9438cf473707ec9866511589a5b84
doc/containers/CCHash/index.html
Module CCHash
Source
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
A hash value is a positive integer.
Always 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)
.
slice s i len state
hashes the slice i, …, i+len-1
of s
into state
.
map f h
is the hasher that takes x
, and uses h
to hash f 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)
Decide which hash function to use depending on the boolean.
Commutative version of list
. Lists that are equal up to permutation will have the same hash.
Commutative version of array
. Arrays that are equal up to permutation will have the same hash.