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