module type HashedType = sig end
Hashtbl.Make
の入力 signature です。type t
val equal : t -> t -> bool
val hash : t -> int
equal
で等価だと判断される場合は、hash
で同じハッシュ値を持つ必要があります。任意のキーの型に対して適用できる (equal
, hash
) の例として、オブジェクトを構造的に比較する ((=)
, Hashtbl.hash
) や、オブジェクトをアドレスで比較する ((==)
, Hashtbl.hash
) があります。後者の場合は mutable や循環構造のキーに適用できます。