10
10
-- Module : Data.IntMap
11
11
-- Copyright : (c) Daan Leijen 2002
12
12
-- (c) Andriy Palamarchuk 2008
13
+ -- (c) Jonathan S. 2016
13
14
-- License : BSD-style
14
15
15
16
-- Stability : provisional
31
32
-- > import Data.IntMap (IntMap)
32
33
-- > import qualified Data.IntMap as IntMap
33
34
--
34
- -- The implementation is based on /big-endian patricia trees/. This data
35
- -- structure performs especially well on binary operations like 'union'
36
- -- and 'intersection'. However, my benchmarks show that it is also
37
- -- (much) faster on insertions and deletions when compared to a generic
38
- -- size-balanced map implementation (see "Data.Map").
39
- --
40
- -- * Chris Okasaki and Andy Gill, \"/Fast Mergeable Integer Maps/\",
41
- -- Workshop on ML, September 1998, pages 77-86,
42
- -- <http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.37.5452>
43
- --
44
- -- * D.R. Morrison, \"/PATRICIA -- Practical Algorithm To Retrieve
45
- -- Information Coded In Alphanumeric/\", Journal of the ACM, 15(4),
46
- -- October 1968, pages 514-534.
47
- --
48
35
-- Operation comments contain the operation time complexity in
49
36
-- the Big-O notation <http://en.wikipedia.org/wiki/Big_O_notation>.
50
37
-- Many operations have a worst-case complexity of /O(min(n,W))/.
@@ -61,37 +48,36 @@ module Data.IntMap
61
48
, foldWithKey
62
49
) where
63
50
64
- import Prelude () -- hide foldr
51
+ import Prelude hiding ( foldr )
65
52
import qualified Data.IntMap.Strict as Strict
66
53
import Data.IntMap.Lazy
67
54
68
55
-- | /O(log n)/. Same as 'insertWith', but the result of the combining function
69
56
-- is evaluated to WHNF before inserted to the map.
70
-
71
57
{-# DEPRECATED insertWith' "As of version 0.5, replaced by 'Data.IntMap.Strict.insertWith'." #-}
58
+ {-# INLINE insertWith' #-}
72
59
insertWith' :: (a -> a -> a ) -> Key -> a -> IntMap a -> IntMap a
73
60
insertWith' = Strict. insertWith
74
61
75
62
-- | /O(log n)/. Same as 'insertWithKey', but the result of the combining
76
63
-- function is evaluated to WHNF before inserted to the map.
77
-
78
64
{-# DEPRECATED insertWithKey' "As of version 0.5, replaced by 'Data.IntMap.Strict.insertWithKey'." #-}
65
+ {-# INLINE insertWithKey' #-}
79
66
insertWithKey' :: (Key -> a -> a -> a ) -> Key -> a -> IntMap a -> IntMap a
80
67
insertWithKey' = Strict. insertWithKey
81
68
82
69
-- | /O(n)/. Fold the values in the map using the given
83
70
-- right-associative binary operator. This function is an equivalent
84
71
-- of 'foldr' and is present for compatibility only.
85
72
{-# DEPRECATED fold "As of version 0.5, replaced by 'foldr'." #-}
73
+ {-# INLINE fold #-}
86
74
fold :: (a -> b -> b ) -> b -> IntMap a -> b
87
75
fold = foldr
88
- {-# INLINE fold #-}
89
76
90
77
-- | /O(n)/. Fold the keys and values in the map using the given
91
78
-- right-associative binary operator. This function is an equivalent
92
79
-- of 'foldrWithKey' and is present for compatibility only.
93
-
94
80
{-# DEPRECATED foldWithKey "As of version 0.5, replaced by 'foldrWithKey'." #-}
81
+ {-# INLINE foldWithKey #-}
95
82
foldWithKey :: (Key -> a -> b -> b ) -> b -> IntMap a -> b
96
83
foldWithKey = foldrWithKey
97
- {-# INLINE foldWithKey #-}
0 commit comments