hashtables 1.2.3.1 → 1.2.3.2
raw patch · 7 files changed
+51/−37 lines, 7 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.HashTable.Class: toList :: (HashTable h) => h s k v -> ST s [(k, v)]
+ Data.HashTable.Class: toList :: HashTable h => h s k v -> ST s [(k, v)]
- Data.HashTable.IO: computeOverhead :: (HashTable h) => IOHashTable h k v -> IO Double
+ Data.HashTable.IO: computeOverhead :: HashTable h => IOHashTable h k v -> IO Double
- Data.HashTable.IO: foldM :: (HashTable h) => (a -> (k, v) -> IO a) -> a -> IOHashTable h k v -> IO a
+ Data.HashTable.IO: foldM :: HashTable h => (a -> (k, v) -> IO a) -> a -> IOHashTable h k v -> IO a
- Data.HashTable.IO: mapM_ :: (HashTable h) => ((k, v) -> IO a) -> IOHashTable h k v -> IO ()
+ Data.HashTable.IO: mapM_ :: HashTable h => ((k, v) -> IO a) -> IOHashTable h k v -> IO ()
- Data.HashTable.ST.Basic: delete :: (Hashable k, Eq k) => (HashTable s k v) -> k -> ST s ()
+ Data.HashTable.ST.Basic: delete :: (Hashable k, Eq k) => HashTable s k v -> k -> ST s ()
- Data.HashTable.ST.Basic: insert :: (Eq k, Hashable k) => (HashTable s k v) -> k -> v -> ST s ()
+ Data.HashTable.ST.Basic: insert :: (Eq k, Hashable k) => HashTable s k v -> k -> v -> ST s ()
- Data.HashTable.ST.Basic: lookup :: (Eq k, Hashable k) => (HashTable s k v) -> k -> ST s (Maybe v)
+ Data.HashTable.ST.Basic: lookup :: (Eq k, Hashable k) => HashTable s k v -> k -> ST s (Maybe v)
- Data.HashTable.ST.Basic: mutate :: (Eq k, Hashable k) => (HashTable s k v) -> k -> (Maybe v -> (Maybe v, a)) -> ST s a
+ Data.HashTable.ST.Basic: mutate :: (Eq k, Hashable k) => HashTable s k v -> k -> (Maybe v -> (Maybe v, a)) -> ST s a
- Data.HashTable.ST.Basic: mutateST :: (Eq k, Hashable k) => (HashTable s k v) -> k -> (Maybe v -> ST s (Maybe v, a)) -> ST s a
+ Data.HashTable.ST.Basic: mutateST :: (Eq k, Hashable k) => HashTable s k v -> k -> (Maybe v -> ST s (Maybe v, a)) -> ST s a
- Data.HashTable.ST.Linear: delete :: (Hashable k, Eq k) => (HashTable s k v) -> k -> ST s ()
+ Data.HashTable.ST.Linear: delete :: (Hashable k, Eq k) => HashTable s k v -> k -> ST s ()
- Data.HashTable.ST.Linear: insert :: (Eq k, Hashable k) => (HashTable s k v) -> k -> v -> ST s ()
+ Data.HashTable.ST.Linear: insert :: (Eq k, Hashable k) => HashTable s k v -> k -> v -> ST s ()
- Data.HashTable.ST.Linear: lookup :: (Eq k, Hashable k) => (HashTable s k v) -> k -> ST s (Maybe v)
+ Data.HashTable.ST.Linear: lookup :: (Eq k, Hashable k) => HashTable s k v -> k -> ST s (Maybe v)
- Data.HashTable.ST.Linear: mutate :: (Eq k, Hashable k) => (HashTable s k v) -> k -> (Maybe v -> (Maybe v, a)) -> ST s a
+ Data.HashTable.ST.Linear: mutate :: (Eq k, Hashable k) => HashTable s k v -> k -> (Maybe v -> (Maybe v, a)) -> ST s a
- Data.HashTable.ST.Linear: mutateST :: (Eq k, Hashable k) => (HashTable s k v) -> k -> (Maybe v -> ST s (Maybe v, a)) -> ST s a
+ Data.HashTable.ST.Linear: mutateST :: (Eq k, Hashable k) => HashTable s k v -> k -> (Maybe v -> ST s (Maybe v, a)) -> ST s a
Files
- cabal.project +1/−0
- changelog.md +10/−2
- hashtables.cabal +3/−2
- src/Data/HashTable/IO.hs +15/−15
- src/Data/HashTable/Internal/IntArray.hs +4/−0
- src/Data/HashTable/ST/Basic.hs +10/−10
- src/Data/HashTable/ST/Cuckoo.hs +8/−8
+ cabal.project view
@@ -0,0 +1,1 @@+packages: .
changelog.md view
@@ -1,5 +1,13 @@ # Hashtables changelog +## 1.2.3.2++ - CPP fix for breakage caused by primitive 0.7 (thx Carter)++ - Fix some haddock syntax errors (thx Frederik Hanghøj Iversen)++ - Fix typo in module reference (thx Don Allen)+ ## 1.2.3.1 - Fix building with GHC <7.10 (thx Vanessa McHale)@@ -7,9 +15,9 @@ ## 1.2.3.0 - update for Semigroup/monoid breakage with GHC 8.4 (thx Fumiaki Kinoshita)- + - Implement mutateST and mutateIO (thx Andy Morris)- + - Fix build breakage w/ "pre" function (thx Andy Morris) ## 1.2.2.1
hashtables.cabal view
@@ -1,5 +1,5 @@ Name: hashtables-Version: 1.2.3.1+Version: 1.2.3.2 Synopsis: Mutable hash tables in the ST monad Homepage: http://github.com/gregorycollins/hashtables License: BSD3@@ -29,7 +29,7 @@ the table can perform acceptably well even when approaching 90% full. Randomized testing shows this implementation of cuckoo hashing to be slightly faster on insert and slightly slower on lookup than- "Data.Hashtable.ST.Basic", while being more space efficient by about a+ "Data.HashTable.ST.Basic", while being more space efficient by about a half-word per key-value mapping. Cuckoo hashing, like the basic hash table implementation using linear probing, can suffer from long delays when the table is resized.@@ -96,6 +96,7 @@ Extra-Source-Files: README.md,+ cabal.project, haddock.sh, benchmark/hashtable-benchmark.cabal, benchmark/LICENSE,
src/Data/HashTable/IO.hs view
@@ -99,7 +99,7 @@ --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:new".+-- | See the documentation for this function in 'Data.HashTable.Class.new'. new :: C.HashTable h => IO (IOHashTable h k v) new = stToIO C.new {-# INLINE new #-}@@ -109,7 +109,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:newSized".+-- 'Data.HashTable.Class.newSized'. newSized :: C.HashTable h => Int -> IO (IOHashTable h k v) newSized = stToIO . C.newSized {-# INLINE newSized #-}@@ -119,7 +119,7 @@ --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:insert".+-- | See the documentation for this function in 'Data.HashTable.Class.insert'. insert :: (C.HashTable h, Eq k, Hashable k) => IOHashTable h k v -> k -> v -> IO () insert h k v = stToIO $ C.insert h k v@@ -133,7 +133,7 @@ --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:delete".+-- | See the documentation for this function in 'Data.HashTable.Class.delete'. delete :: (C.HashTable h, Eq k, Hashable k) => IOHashTable h k v -> k -> IO () delete h k = stToIO $ C.delete h k@@ -147,7 +147,7 @@ --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:lookup".+-- | See the documentation for this function in 'Data.HashTable.Class.lookup'. lookup :: (C.HashTable h, Eq k, Hashable k) => IOHashTable h k v -> k -> IO (Maybe v) lookup h k = stToIO $ C.lookup h k@@ -160,7 +160,7 @@ CuckooHashTable k v -> k -> IO (Maybe v) #-} --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:lookupIndex".+-- | See the documentation for this function in 'Data.HashTable.Class.lookupIndex'. lookupIndex :: (C.HashTable h, Eq k, Hashable k) => IOHashTable h k v -> k -> IO (Maybe Word) lookupIndex h k = stToIO $ C.lookupIndex h k@@ -173,7 +173,7 @@ CuckooHashTable k v -> k -> IO (Maybe Word) #-} --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:nextByIndex".+-- | See the documentation for this function in 'Data.HashTable.Class.nextByIndex'. nextByIndex :: (C.HashTable h, Eq k, Hashable k) => IOHashTable h k v -> Word -> IO (Maybe (Word,k,v)) nextByIndex h k = stToIO $ C.nextByIndex h k@@ -186,7 +186,7 @@ CuckooHashTable k v -> Word -> IO (Maybe (Word,k,v)) #-} --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:mutateST".+-- | See the documentation for this function in 'Data.HashTable.Class.mutateST'. mutateIO :: (C.HashTable h, Eq k, Hashable k) => IOHashTable h k v -> k -> (Maybe v -> IO (Maybe v, a)) -> IO a mutateIO h k f = stToIO $ C.mutateST h k (ioToST . f)@@ -199,7 +199,7 @@ CuckooHashTable k v -> k -> (Maybe v -> IO (Maybe v, a)) -> IO a #-} --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:mutate".+-- | See the documentation for this function in 'Data.HashTable.Class.mutate'. mutate :: (C.HashTable h, Eq k, Hashable k) => IOHashTable h k v -> k -> (Maybe v -> (Maybe v, a)) -> IO a mutate h k f = stToIO $ C.mutate h k f@@ -214,7 +214,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:fromList".+-- 'Data.HashTable.Class.fromList'. fromList :: (C.HashTable h, Eq k, Hashable k) => [(k,v)] -> IO (IOHashTable h k v) fromList = stToIO . C.fromList@@ -229,7 +229,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:fromListWithSizeHint".+-- 'Data.HashTable.Class.fromListWithSizeHint'. fromListWithSizeHint :: (C.HashTable h, Eq k, Hashable k) => Int -> [(k,v)] -> IO (IOHashTable h k v) fromListWithSizeHint n = stToIO . C.fromListWithSizeHint n@@ -243,7 +243,7 @@ --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:toList".+-- | See the documentation for this function in 'Data.HashTable.Class.toList'. toList :: (C.HashTable h, Eq k, Hashable k) => IOHashTable h k v -> IO [(k,v)] toList = stToIO . C.toList@@ -257,7 +257,7 @@ --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:foldM".+-- | See the documentation for this function in 'Data.HashTable.Class.foldM'. foldM :: (C.HashTable h) => (a -> (k,v) -> IO a) -> a@@ -275,7 +275,7 @@ --------------------------------------------------------------------------------- | See the documentation for this function in "Data.HashTable.Class#v:mapM_".+-- | See the documentation for this function in 'Data.HashTable.Class.mapM_'. mapM_ :: (C.HashTable h) => ((k,v) -> IO a) -> IOHashTable h k v -> IO () mapM_ f ht = stToIO $ C.mapM_ f' ht where@@ -291,7 +291,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:computeOverhead".+-- 'Data.HashTable.Class.computeOverhead'. computeOverhead :: (C.HashTable h) => IOHashTable h k v -> IO Double computeOverhead = stToIO . C.computeOverhead {-# INLINE computeOverhead #-}
src/Data/HashTable/Internal/IntArray.hs view
@@ -112,4 +112,8 @@ toPtr :: IntArray s -> Ptr a toPtr (IA a) = Ptr a# where+#if MIN_VERSION_primitive(0,7,0)+ !(Ptr !a#) = A.mutableByteArrayContents a+#else !(Addr !a#) = A.mutableByteArrayContents a+#endif
src/Data/HashTable/ST/Basic.hs view
@@ -185,7 +185,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:new".+-- 'Data.HashTable.Class.new'. new :: ST s (HashTable s k v) new = newSized 1 {-# INLINE new #-}@@ -193,7 +193,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:newSized".+-- 'Data.HashTable.Class.newSized'. newSized :: Int -> ST s (HashTable s k v) newSized n = do debug $ "entering: newSized " ++ show n@@ -219,7 +219,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:delete".+-- 'Data.HashTable.Class.delete'. delete :: (Hashable k, Eq k) => (HashTable s k v) -> k@@ -235,7 +235,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:lookup".+-- 'Data.HashTable.Class.lookup'. lookup :: (Eq k, Hashable k) => (HashTable s k v) -> k -> ST s (Maybe v) lookup htRef !k = do ht <- readRef htRef@@ -287,7 +287,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:insert".+-- 'Data.HashTable.Class.insert'. insert :: (Eq k, Hashable k) => (HashTable s k v) -> k@@ -312,7 +312,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:mutate".+-- 'Data.HashTable.Class.mutate'. mutate :: (Eq k, Hashable k) => (HashTable s k v) -> k@@ -324,7 +324,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:mutateST".+-- 'Data.HashTable.Class.mutateST'. mutateST :: (Eq k, Hashable k) => (HashTable s k v) -> k@@ -362,7 +362,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:foldM".+-- 'Data.HashTable.Class.foldM'. foldM :: (a -> (k,v) -> ST s a) -> a -> HashTable s k v -> ST s a foldM f seed0 htRef = readRef htRef >>= work where@@ -382,7 +382,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:mapM_".+-- 'Data.HashTable.Class.mapM_'. mapM_ :: ((k,v) -> ST s b) -> HashTable s k v -> ST s () mapM_ f htRef = readRef htRef >>= work where@@ -402,7 +402,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:computeOverhead".+-- 'Data.HashTable.Class.computeOverhead'. computeOverhead :: HashTable s k v -> ST s Double computeOverhead htRef = readRef htRef >>= work where
src/Data/HashTable/ST/Cuckoo.hs view
@@ -149,7 +149,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:new".+-- 'Data.HashTable.Class.new'. new :: ST s (HashTable s k v) new = newSizedReal 2 >>= newRef {-# INLINE new #-}@@ -157,7 +157,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:newSized".+-- 'Data.HashTable.Class.newSized'. newSized :: Int -> ST s (HashTable s k v) newSized n = do let n' = (n + numElemsInCacheLine - 1) `div` numElemsInCacheLine@@ -168,7 +168,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:insert".+-- 'Data.HashTable.Class.insert'. insert :: (Eq k, Hashable k) => HashTable s k v -> k -> v -> ST s () insert ht !k !v = readRef ht >>= \h -> insert' h k v >>= writeRef ht @@ -199,7 +199,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:computeOverhead".+-- 'Data.HashTable.Class.computeOverhead'. computeOverhead :: HashTable s k v -> ST s Double computeOverhead htRef = readRef htRef >>= work where@@ -222,7 +222,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:delete".+-- 'Data.HashTable.Class.delete'. delete :: (Hashable k, Eq k) => HashTable s k v -> k@@ -243,7 +243,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:lookup".+-- 'Data.HashTable.Class.lookup'. lookup :: (Eq k, Hashable k) => HashTable s k v -> k@@ -321,7 +321,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:foldM".+-- 'Data.HashTable.Class.foldM'. foldM :: (a -> (k,v) -> ST s a) -> a -> HashTable s k v@@ -356,7 +356,7 @@ ------------------------------------------------------------------------------ -- | See the documentation for this function in--- "Data.HashTable.Class#v:mapM_".+-- 'Data.HashTable.Class.mapM_'. mapM_ :: ((k,v) -> ST s a) -> HashTable s k v -> ST s ()