map :: (a -> b) -> IntervalMap k a -> IntervalMap k b

IntervalMap - Data.IntervalMap.Generic.Lazy  Data.IntervalMap.Lazy  

O(n). Map a function over all values in the map.

map :: Bitstream α => (Bool -> Bool) -> α -> α

bitstream - Data.Bitstream.Lazy  Data.Bitstream  

O(n) Map a function over a Bitstream.

map :: (Char -> Char) -> ByteString -> ByteString

bytestring - Data.ByteString.Lazy.Char8  

O(n) map f xs is the ByteString obtained by applying f to each element of xs

map :: (Word8 -> Word8) -> ByteString -> ByteString

bytestring - Data.ByteString.Lazy  

O(n) map f xs is the ByteString obtained by applying f to each element of xs.

map :: (a -> b) -> IntMap a -> IntMap b

containers - Data.IntMap.Lazy  

O(n). Map a function over all values in the map.

map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]
map :: (a -> b) -> Map k a -> Map k b

containers - Data.Map.Lazy  

O(n). Map a function over all values in the map.

map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]
map :: (v -> t) -> EnumMapMap k v -> EnumMapMap k t Class Method

enummapmap - Data.EnumMapMap.Lazy  

Map a function over all values in the EnumMapMap.

map :: forall k a b. (a -> b) -> EnumMap k a -> EnumMap k b
map :: (Char -> Char) -> Text -> Text

text - Data.Text.Lazy  

O(n) map f t is the Text obtained by applying f to each element of t. Subject to fusion. Performs replacement on invalid scalar values.

containers - Data.Map.Lazy  

An efficient implementation of ordered maps from keys to values (dictionaries).

API of this module is strict in the keys, but lazy in the values. If you need value-strict maps, use Data.Map.Strict instead. The Map type itself is shared between the lazy and strict modules, meaning that the same Map value can be passed to functions in both modules (although that is rarely needed).

These modules are intended to be imported qualified, to avoid name clashes with Prelude functions, e.g.

 import qualified Data.Map.Lazy as Map

The implementation of Map is based on size balanced binary trees (or trees of bounded balance) as described by:

  • Stephen Adams, "Efficient sets: a balancing act", Journal of Functional Programming 3(4):553-562, October 1993, http://www.swiss.ai.mit.edu/~adams/BB/.
    • J. Nievergelt and E.M. Reingold, "Binary search trees of bounded balance", SIAM journal of computing 2(1), March 1973.

Note that the implementation is left-biased -- the elements of a first argument are always preferred to the second, for example in union or insert.

Warning: The size of the map must not exceed maxBound::Int. Violation of this condition is not detected and if the size limit is exceeded, its behaviour is undefined.

Operation comments contain the operation time complexity in the Big-O notation (http://en.wikipedia.org/wiki/Big_O_notation).

showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String

containers - Data.Map.Lazy  

O(n). The expression (showTreeWith showelem hang wide map) shows the tree that implements the map. Elements are shown using the showElem function. If hang is True, a hanging tree is shown otherwise a rotated tree is shown. If wide is True, an extra wide version is shown.

 Map> let t = fromDistinctAscList [(x,()) | x <- [1..5]]
 Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True False t
 (4,())
 +--(2,())
 |  +--(1,())
 |  +--(3,())
 +--(5,())

 Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True True t
 (4,())
 |
 +--(2,())
 |  |
 |  +--(1,())
 |  |
 |  +--(3,())
 |
 +--(5,())

 Map> putStrLn $ showTreeWith (\k x -> show (k,x)) False True t
 +--(5,())
 |
 (4,())
 |
 |  +--(3,())
 |  |
 +--(2,())
    |
    +--(1,())
foldlWithKey :: (a -> Key -> b -> a) -> a -> IntMap b -> a

containers - Data.IntMap.Lazy  

O(n). Fold the keys and values in the map using the given left-associative binary operator, such that foldlWithKey f z == foldl (\z' (kx, x) -> f z' kx x) z . toAscList.

For example,

keys = reverse . foldlWithKey (\ks k x -> k:ks) []
let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"
foldrWithKey :: (Key -> a -> b -> b) -> b -> IntMap a -> b

containers - Data.IntMap.Lazy  

O(n). Fold the keys and values in the map using the given right-associative binary operator, such that foldrWithKey f z == foldr (uncurry f) z . toAscList.

For example,

keys map = foldrWithKey (\k x ks -> k:ks) [] map
let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"
foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> a

containers - Data.Map.Lazy  

O(n). Fold the keys and values in the map using the given left-associative binary operator, such that foldlWithKey f z == foldl (\z' (kx, x) -> f z' kx x) z . toAscList.

For example,

keys = reverse . foldlWithKey (\ks k x -> k:ks) []
let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"
foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b

containers - Data.Map.Lazy  

O(n). Fold the keys and values in the map using the given right-associative binary operator, such that foldrWithKey f z == foldr (uncurry f) z . toAscList.

For example,

keys map = foldrWithKey (\k x ks -> k:ks) [] map
let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"

containers - Data.Map.Lazy  Data.Map.Strict  

O(1). Is the map empty?

Data.Map.null (empty)           == True
Data.Map.null (singleton 1 'a') == False

data-stringmap - Data.StringMap.Lazy  

An efficient implementation of maps from strings to arbitrary values.

Values can associated with an arbitrary byte key. Searching for keys is very fast, but the prefix tree probably consumes more memory than Data.Map. The main differences are the special prefixFind functions, which can be used to perform prefix queries. The interface is heavily borrowed from Data.Map and Data.IntMap.

Most other function names clash with Prelude names, therefore this module is usually imported qualified, e.g.

 import Data.StringMap (StringMap)
 import qualified Data.StringMap as T

Many functions have a worst-case complexity of O(min(n,L)). This means that the operation can become linear with the number of elements with a maximum of L, the length of the key (the number of bytes in the list). The functions for searching a prefix have a worst-case complexity of O(max(L,R)). This means that the operation can become linear with R, the number of elements found for the prefix, with a minimum of L.

The module exports include the internal data types, their constructors and access functions for ultimate flexibility. Derived modules should not export these (as shown in Holumbus.Data.StrMap) to provide only a restricted interface.