mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-08 12:15:32 -05:00
add Hash.const0 for trivial hash function that ignores its input
This commit is contained in:
parent
632526e407
commit
9ac7984f74
2 changed files with 7 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ let combine4 a b c d =
|
||||||
(** {2 Combinators} *)
|
(** {2 Combinators} *)
|
||||||
|
|
||||||
let const h _ = h
|
let const h _ = h
|
||||||
|
let const0 _ = 0
|
||||||
|
|
||||||
let int i = i land max_int
|
let int i = i land max_int
|
||||||
let bool b = if b then 1 else 2
|
let bool b = if b then 1 else 2
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,12 @@ type 'a t = 'a -> hash
|
||||||
val const : hash -> _ t
|
val const : hash -> _ t
|
||||||
(** [return h] hashes any value into [h]. Use with caution!. *)
|
(** [return h] hashes any value into [h]. Use with caution!. *)
|
||||||
|
|
||||||
|
val const0 : _ t
|
||||||
|
(** 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)]
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val int : int t
|
val int : int t
|
||||||
val bool : bool t
|
val bool : bool t
|
||||||
val char : char t
|
val char : char t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue