unordered-containers 0.2.3.3 → 0.2.4.0
raw patch · 5 files changed
+28/−48 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.HashMap.Lazy: mapWithKey :: (k -> v1 -> v2) -> HashMap k v1 -> HashMap k v2
+ Data.HashMap.Strict: mapWithKey :: (k -> v1 -> v2) -> HashMap k v1 -> HashMap k v2
Files
- Data/HashMap/Base.hs +3/−1
- Data/HashMap/Lazy.hs +1/−0
- Data/HashMap/Strict.hs +3/−1
- benchmarks/Benchmarks.hs +19/−44
- unordered-containers.cabal +2/−2
Data/HashMap/Base.hs view
@@ -31,6 +31,7 @@ -- * Transformations , map+ , mapWithKey , traverseWithKey -- * Difference and intersection@@ -313,7 +314,7 @@ | otherwise = runST (two s h k x hy ky y) go h k x s t@(BitmapIndexed b ary) | b .&. m == 0 =- let ary' = A.insert ary i $! Leaf h (L k x)+ let !ary' = A.insert ary i $! Leaf h (L k x) in bitmapIndexedOrFull (b .|. m) ary' | otherwise = let !st = A.index ary i@@ -695,6 +696,7 @@ A.map' (\ (L k v) -> L k (f k v)) ary {-# INLINE mapWithKey #-} +-- | /O(n)/ Transform this map by applying a function to every value. map :: (v1 -> v2) -> HashMap k v1 -> HashMap k v2 map f = mapWithKey (const f) {-# INLINE map #-}
Data/HashMap/Lazy.hs view
@@ -56,6 +56,7 @@ -- * Transformations , HM.map+ , mapWithKey , traverseWithKey -- * Difference and intersection
Data/HashMap/Strict.hs view
@@ -56,6 +56,7 @@ -- * Transformations , map+ , mapWithKey , traverseWithKey -- * Difference and intersection@@ -92,7 +93,7 @@ import qualified Data.HashMap.Base as HM import Data.HashMap.Base hiding ( adjust, fromList, fromListWith, insert, insertWith, intersectionWith,- map, singleton, unionWith)+ map, mapWithKey, singleton, unionWith) import Data.HashMap.Unsafe (runST) -- $strictness@@ -330,6 +331,7 @@ Collision h $ A.map' (\ (L k v) -> let !v' = f k v in L k v') ary {-# INLINE mapWithKey #-} +-- | /O(n)/ Transform this map by applying a function to every value. map :: (v1 -> v2) -> HashMap k v1 -> HashMap k v2 map f = mapWithKey (const f) {-# INLINE map #-}
benchmarks/Benchmarks.hs view
@@ -191,39 +191,29 @@ -- fromList , bgroup "fromList"- [ bgroup name- [ bgroup "long"- [ bench "String" $ whnf fl1 elems- , bench "ByteString" $ whnf fl2 elemsBS- , bench "Int" $ whnf fl3 elemsI- ]- , bgroup "short"- [ bench "String" $ whnf fl1 elemsDup- , bench "ByteString" $ whnf fl2 elemsDupBS- , bench "Int" $ whnf fl3 elemsDupI- ]+ [ bgroup "long"+ [ bench "String" $ whnf HM.fromList elems+ , bench "ByteString" $ whnf HM.fromList elemsBS+ , bench "Int" $ whnf HM.fromList elemsI ]- | (name,fl1,fl2,fl3)- <- [("Base",HM.fromList,HM.fromList,HM.fromList)- ,("insert",fromList_insert,fromList_insert,fromList_insert)]+ , bgroup "short"+ [ bench "String" $ whnf HM.fromList elemsDup+ , bench "ByteString" $ whnf HM.fromList elemsDupBS+ , bench "Int" $ whnf HM.fromList elemsDupI+ ] ]- -- fromList+ -- fromListWith , bgroup "fromListWith"- [ bgroup name- [ bgroup "long"- [ bench "String" $ whnf (fl1 (+)) elems- , bench "ByteString" $ whnf (fl2 (+)) elemsBS- , bench "Int" $ whnf (fl3 (+)) elemsI- ]- , bgroup "short"- [ bench "String" $ whnf (fl1 (+)) elemsDup- , bench "ByteString" $ whnf (fl2 (+)) elemsDupBS- , bench "Int" $ whnf (fl3 (+)) elemsDupI- ]+ [ bgroup "long"+ [ bench "String" $ whnf (HM.fromListWith (+)) elems+ , bench "ByteString" $ whnf (HM.fromListWith (+)) elemsBS+ , bench "Int" $ whnf (HM.fromListWith (+)) elemsI ]- | (name,fl1,fl2,fl3)- <- [("Base",HM.fromListWith,HM.fromListWith,HM.fromListWith)- ,("insert",fromListWith_insert,fromListWith_insert,fromListWith_insert)]+ , bgroup "short"+ [ bench "String" $ whnf (HM.fromListWith (+)) elemsDup+ , bench "ByteString" $ whnf (HM.fromListWith (+)) elemsDupBS+ , bench "Int" $ whnf (HM.fromListWith (+)) elemsDupI+ ] ] ] ]@@ -334,18 +324,3 @@ deleteIM :: [Int] -> IM.IntMap Int -> IM.IntMap Int deleteIM xs m0 = foldl' (\m k -> IM.delete k m) m0 xs----------------------------------------------------------------------------- * Reference implementations--fromList_insert :: (Eq k, Hashable k) => [(k, v)] -> HM.HashMap k v-fromList_insert = foldl' (\ m (k, v) -> HM.insert k v m) HM.empty-#if __GLASGOW_HASKELL__ >= 700-{-# INLINABLE fromList_insert #-}-#endif--fromListWith_insert :: (Eq k, Hashable k) => (v -> v -> v) -> [(k, v)] -> HM.HashMap k v-fromListWith_insert f = foldl' (\ m (k, v) -> HM.insertWith f k v m) HM.empty-#if __GLASGOW_HASKELL__ >= 700-{-# INLINABLE fromListWith_insert #-}-#endif
unordered-containers.cabal view
@@ -1,5 +1,5 @@ name: unordered-containers-version: 0.2.3.3+version: 0.2.4.0 synopsis: Efficient hashing-based container types description: Efficient hashing-based container types. The containers have been@@ -14,7 +14,7 @@ maintainer: johan.tibell@gmail.com Homepage: https://github.com/tibbe/unordered-containers bug-reports: https://github.com/tibbe/unordered-containers/issues-copyright: 2010-2012 Johan Tibell+copyright: 2010-2014 Johan Tibell 2010 Edward Z. Yang category: Data build-type: Simple