package containers
Install
Dune Dependency
Authors
Maintainers
Sources
md5=2c4ada818bacf65c893aa7792a8d7abc
sha512=309856cc438367ff962ea1bddeb4a0a6cce5b3d32bf482e148276d17022b3549e809d5ceb0a441bd649feaf4d90aa0b16c97e4d241d1d21bb3a07834a963eb1b
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.