mapWithKey

mapWithKey :: (Key -> a -> b) -> IntMap a -> IntMap b
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Map a function over all values in the map. > let f key x = (show key) ++ ":" ++ x > mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]
mapWithKey :: (k -> a -> b) -> Map k a -> Map k b
containers Data.Map.Lazy, containers Data.Map.Strict
O(n). Map a function over all values in the map. > let f key x = (show key) ++ ":" ++ x > mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]
foldMapWithKey :: Monoid m => (Key -> a -> m) -> IntMap a -> m
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n). Fold the keys and values in the map using the given monoid, such that > foldMapWithKey f = fold . mapWithKey f This can be an asymptotically faster than foldrWithKey or foldlWithKey for some monoids.
foldMapWithKey :: Monoid m => (k -> a -> m) -> Map k a -> m
containers Data.Map.Lazy, containers Data.Map.Strict
O(n). Fold the keys and values in the map using the given monoid, such that > foldMapWithKey f = fold . mapWithKey f This can be an asymptotically faster than foldrWithKey or foldlWithKey for some monoids.