module type HashedType =sig
..end
函式子 Hashtbl.Make
的輸入簽名。
type
t
雜湊表鍵的類型。
val equal : t -> t -> bool
用於比較鍵的相等性謂詞。
val hash : t -> int
鍵上的雜湊函式。它必須滿足:如果根據 equal
兩個鍵相等,那麼它們的雜湊值(由 hash
計算)也必須相同。範例:適合任意鍵類型的 (equal
, hash
) 配對包括
(=)
, Hashtbl.HashedType.hash
) 用於依結構比較物件(前提是物件不包含浮點數)(fun x y -> compare x y = 0)
, Hashtbl.HashedType.hash
) 用於依結構比較物件並正確處理 nan
(==)
, Hashtbl.HashedType.hash
) 用於依實體相等性比較物件(例如,用於可變或循環物件)。