X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FHashTable.hs;h=9fbe7353c19ca0362e6bcee0b7f93fe8b1a72f19;hb=b8ac498face4c8b16c06d30fbc86666b7dc28173;hp=04297976dd23104a17c890e1af68da02ed5f1204;hpb=81107b8d6d8c62f90fb1fdcde31d3bac3739e356;p=ghc-base.git diff --git a/Data/HashTable.hs b/Data/HashTable.hs index 0429797..9fbe735 100644 --- a/Data/HashTable.hs +++ b/Data/HashTable.hs @@ -157,7 +157,8 @@ hashString = fromIntegral . foldr f 0 where f c m = ord c + (m * 128) `rem` fromIntegral prime -- | A prime larger than the maximum hash table size -prime = 1500007 :: Int32 +prime :: Int32 +prime = 1500007 -- ----------------------------------------------------------------------------- -- Parameters @@ -174,10 +175,14 @@ hLOAD = 4 :: Int32 -- Maximum average load of a single hash bucket -- ----------------------------------------------------------------------------- -- Creating a new hash table --- | Creates a new hash table +-- | Creates a new hash table. The following property should hold for the @eq@ +-- and @hash@ functions passed to 'new': +-- +-- > eq A B => hash A == hash B +-- new - :: (key -> key -> Bool) -- ^ An equality comparison on keys - -> (key -> Int32) -- ^ A hash function on keys + :: (key -> key -> Bool) -- ^ @eq@: An equality comparison on keys + -> (key -> Int32) -- ^ @hash@: A hash function on keys -> IO (HashTable key val) -- ^ Returns: an empty hash table new cmp hash_fn = do