<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Data.IntMap</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_Data-IntMap.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">containers-0.4.2.1: Assorted concrete container types</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr><tr><th>Safe Haskell</th><td>Trustworthy</td></tr></table><p class="caption">Data.IntMap</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Map type </a></li><li><a href="#g:2">Operators </a></li><li><a href="#g:3">Query </a></li><li><a href="#g:4">Construction </a><ul><li><a href="#g:5">Insertion </a></li><li><a href="#g:6">Delete/Update </a></li></ul></li><li><a href="#g:7">Combine </a><ul><li><a href="#g:8">Union </a></li><li><a href="#g:9">Difference </a></li><li><a href="#g:10">Intersection </a></li></ul></li><li><a href="#g:11">Traversal </a><ul><li><a href="#g:12">Map </a></li></ul></li><li><a href="#g:13">Folds </a><ul><li><a href="#g:14">Strict folds </a></li><li><a href="#g:15">Legacy folds </a></li></ul></li><li><a href="#g:16">Conversion </a><ul><li><a href="#g:17">Lists </a></li><li><a href="#g:18">Ordered lists </a></li></ul></li><li><a href="#g:19">Filter </a></li><li><a href="#g:20">Submap </a></li><li><a href="#g:21">Min/Max </a></li><li><a href="#g:22">Debugging </a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>An efficient implementation of maps from integer keys to values. </p><p>Since many function names (but not the type name) clash with <a href="../base-4.5.1.0/Prelude.html">Prelude</a> names, this module is usually imported <code>qualified</code>, e.g. </p><pre> import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap </pre><p>The implementation is based on <em>big-endian patricia trees</em>. This data structure performs especially well on binary operations like <code><a href="Data-IntMap.html#v:union">union</a></code> and <code><a href="Data-IntMap.html#v:intersection">intersection</a></code>. However, my benchmarks show that it is also (much) faster on insertions and deletions when compared to a generic size-balanced map implementation (see <a href="Data-Map.html">Data.Map</a>). </p><ul><li> Chris Okasaki and Andy Gill, "<em>Fast Mergeable Integer Maps</em>", Workshop on ML, September 1998, pages 77-86, <a href="http://citeseer.ist.psu.edu/okasaki98fast.html">http://citeseer.ist.psu.edu/okasaki98fast.html</a> </li><li> D.R. Morrison, "/PATRICIA -- Practical Algorithm To Retrieve Information Coded In Alphanumeric/", Journal of the ACM, 15(4), October 1968, pages 514-534. </li></ul><p>Operation comments contain the operation time complexity in the Big-O notation <a href="http://en.wikipedia.org/wiki/Big_O_notation">http://en.wikipedia.org/wiki/Big_O_notation</a>. Many operations have a worst-case complexity of <em>O(min(n,W))</em>. This means that the operation can become linear in the number of elements with a maximum of <em>W</em> -- the number of bits in an <code><a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></code> (32 or 64). </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:IntMap">IntMap</a> a</li><li class="src short"><span class="keyword">type</span> <a href="#t:Key">Key</a> = <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:-33-">(!)</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:Key">Key</a> -> a</li><li class="src short"><a href="#v:-92--92-">(\\)</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:null">null</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:size">size</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:member">member</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:notMember">notMember</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:lookup">lookup</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a</li><li class="src short"><a href="#v:findWithDefault">findWithDefault</a> :: a -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> a</li><li class="src short"><a href="#v:empty">empty</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:singleton">singleton</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:insert">insert</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:insertWith">insertWith</a> :: (a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:insertWith-39-">insertWith'</a> :: (a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:insertWithKey">insertWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:insertWithKey-39-">insertWithKey'</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:insertLookupWithKey">insertLookupWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:delete">delete</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:adjust">adjust</a> :: (a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:adjustWithKey">adjustWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:update">update</a> :: (a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:updateWithKey">updateWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:updateLookupWithKey">updateLookupWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:alter">alter</a> :: (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:union">union</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:unionWith">unionWith</a> :: (a -> a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:unionWithKey">unionWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:unions">unions</a> :: [<a href="Data-IntMap.html#t:IntMap">IntMap</a> a] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:unionsWith">unionsWith</a> :: (a -> a -> a) -> [<a href="Data-IntMap.html#t:IntMap">IntMap</a> a] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:difference">difference</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:differenceWith">differenceWith</a> :: (a -> b -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:differenceWithKey">differenceWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> b -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:intersection">intersection</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:intersectionWith">intersectionWith</a> :: (a -> b -> c) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> c</li><li class="src short"><a href="#v:intersectionWithKey">intersectionWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> b -> c) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> c</li><li class="src short"><a href="#v:map">map</a> :: (a -> b) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</li><li class="src short"><a href="#v:mapWithKey">mapWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> b) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</li><li class="src short"><a href="#v:mapAccum">mapAccum</a> :: (a -> b -> (a, c)) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</li><li class="src short"><a href="#v:mapAccumWithKey">mapAccumWithKey</a> :: (a -> <a href="Data-IntMap.html#t:Key">Key</a> -> b -> (a, c)) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</li><li class="src short"><a href="#v:mapAccumRWithKey">mapAccumRWithKey</a> :: (a -> <a href="Data-IntMap.html#t:Key">Key</a> -> b -> (a, c)) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</li><li class="src short"><a href="#v:foldr">foldr</a> :: (a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</li><li class="src short"><a href="#v:foldl">foldl</a> :: (a -> b -> a) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> a</li><li class="src short"><a href="#v:foldrWithKey">foldrWithKey</a> :: (<a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</li><li class="src short"><a href="#v:foldlWithKey">foldlWithKey</a> :: (a -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> b -> a) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> a</li><li class="src short"><a href="#v:foldr-39-">foldr'</a> :: (a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</li><li class="src short"><a href="#v:foldl-39-">foldl'</a> :: (a -> b -> a) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> a</li><li class="src short"><a href="#v:foldrWithKey-39-">foldrWithKey'</a> :: (<a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</li><li class="src short"><a href="#v:foldlWithKey-39-">foldlWithKey'</a> :: (a -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> b -> a) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> a</li><li class="src short"><a href="#v:fold">fold</a> :: (a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</li><li class="src short"><a href="#v:foldWithKey">foldWithKey</a> :: (<a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</li><li class="src short"><a href="#v:elems">elems</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [a]</li><li class="src short"><a href="#v:keys">keys</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [<a href="Data-IntMap.html#t:Key">Key</a>]</li><li class="src short"><a href="#v:keysSet">keysSet</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntSet.html#t:IntSet">IntSet</a></li><li class="src short"><a href="#v:assocs">assocs</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)]</li><li class="src short"><a href="#v:toList">toList</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)]</li><li class="src short"><a href="#v:fromList">fromList</a> :: [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:fromListWith">fromListWith</a> :: (a -> a -> a) -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:fromListWithKey">fromListWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:toAscList">toAscList</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)]</li><li class="src short"><a href="#v:fromAscList">fromAscList</a> :: [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:fromAscListWith">fromAscListWith</a> :: (a -> a -> a) -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:fromAscListWithKey">fromAscListWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:fromDistinctAscList">fromDistinctAscList</a> :: <span class="keyword">forall</span> a. [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:filter">filter</a> :: (a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:filterWithKey">filterWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:partition">partition</a> :: (a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:partitionWithKey">partitionWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:mapMaybe">mapMaybe</a> :: (a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> b) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</li><li class="src short"><a href="#v:mapMaybeWithKey">mapMaybeWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> b) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</li><li class="src short"><a href="#v:mapEither">mapEither</a> :: (a -> <a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> b c) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> b, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</li><li class="src short"><a href="#v:mapEitherWithKey">mapEitherWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> b c) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> b, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</li><li class="src short"><a href="#v:split">split</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:splitLookup">splitLookup</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a, <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:isSubmapOf">isSubmapOf</a> :: <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> a => <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isSubmapOfBy">isSubmapOfBy</a> :: (a -> b -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isProperSubmapOf">isProperSubmapOf</a> :: <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> a => <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isProperSubmapOfBy">isProperSubmapOfBy</a> :: (a -> b -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:findMin">findMin</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:Key">Key</a>, a)</li><li class="src short"><a href="#v:findMax">findMax</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:Key">Key</a>, a)</li><li class="src short"><a href="#v:deleteMin">deleteMin</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:deleteMax">deleteMax</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:deleteFindMin">deleteFindMin</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:deleteFindMax">deleteFindMax</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:updateMin">updateMin</a> :: (a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:updateMax">updateMax</a> :: (a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:updateMinWithKey">updateMinWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:updateMaxWithKey">updateMaxWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:minView">minView</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:maxView">maxView</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:minViewWithKey">minViewWithKey</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> ((<a href="Data-IntMap.html#t:Key">Key</a>, a), <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:maxViewWithKey">maxViewWithKey</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> ((<a href="Data-IntMap.html#t:Key">Key</a>, a), <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:showTree">showTree</a> :: <a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> a => <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:showTreeWith">showTreeWith</a> :: <a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> a => <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li></ul></div><div id="interface"><h1 id="g:1">Map type </h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:IntMap" class="def">IntMap</a> a </p><div class="doc"><p>A map of integers to values <code>a</code>. </p></div><div class="subs instances"><p id="control.i:IntMap" class="caption collapser" onclick="toggleSection('i:IntMap')">Instances</p><div id="section.i:IntMap" class="show"><table><tr><td class="src"><a href="../base-4.5.1.0/Control-Monad.html#t:Functor">Functor</a> <a href="Data-IntMap.html#t:IntMap">IntMap</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Typeable-Internal.html#t:Typeable1">Typeable1</a> <a href="Data-IntMap.html#t:IntMap">IntMap</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Foldable.html#t:Foldable">Foldable</a> <a href="Data-IntMap.html#t:IntMap">IntMap</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Traversable.html#t:Traversable">Traversable</a> <a href="Data-IntMap.html#t:IntMap">IntMap</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> a => <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Data.html#t:Data">Data</a> a => <a href="../base-4.5.1.0/Data-Data.html#t:Data">Data</a> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Ord.html#t:Ord">Ord</a> a => <a href="../base-4.5.1.0/Data-Ord.html#t:Ord">Ord</a> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Text-Read.html#t:Read">Read</a> e => <a href="../base-4.5.1.0/Text-Read.html#t:Read">Read</a> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> e)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> a => <a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../deepseq-1.3.0.0/Control-DeepSeq.html#t:NFData">NFData</a> a => <a href="../deepseq-1.3.0.0/Control-DeepSeq.html#t:NFData">NFData</a> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Key" class="def">Key</a> = <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></p></div><h1 id="g:2">Operators </h1><div class="top"><p class="src"><a name="v:-33-" class="def">(!)</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:Key">Key</a> -> a</p><div class="doc"><p><em>O(min(n,W))</em>. Find the value at a key. Calls <code><a href="../base-4.5.1.0/Prelude.html#v:error">error</a></code> when the element can not be found. </p><pre> fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map fromList [(5,'a'), (3,'b')] ! 5 == 'a' </pre></div></div><div class="top"><p class="src"><a name="v:-92--92-" class="def">(\\)</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p>Same as <code><a href="Data-IntMap.html#v:difference">difference</a></code>. </p></div></div><h1 id="g:3">Query </h1><div class="top"><p class="src"><a name="v:null" class="def">null</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><em>O(1)</em>. Is the map empty? </p><pre> Data.IntMap.null (empty) == True Data.IntMap.null (singleton 1 'a') == False </pre></div></div><div class="top"><p class="src"><a name="v:size" class="def">size</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></p><div class="doc"><p><em>O(n)</em>. Number of elements in the map. </p><pre> size empty == 0 size (singleton 1 'a') == 1 size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3 </pre></div></div><div class="top"><p class="src"><a name="v:member" class="def">member</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><em>O(min(n,W))</em>. Is the key a member of the map? </p><pre> member 5 (fromList [(5,'a'), (3,'b')]) == True member 1 (fromList [(5,'a'), (3,'b')]) == False </pre></div></div><div class="top"><p class="src"><a name="v:notMember" class="def">notMember</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><em>O(log n)</em>. Is the key not a member of the map? </p><pre> notMember 5 (fromList [(5,'a'), (3,'b')]) == False notMember 1 (fromList [(5,'a'), (3,'b')]) == True </pre></div></div><div class="top"><p class="src"><a name="v:lookup" class="def">lookup</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. Lookup the value at a key in the map. See also <code><a href="Data-Map.html#v:lookup">lookup</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:findWithDefault" class="def">findWithDefault</a> :: a -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> a</p><div class="doc"><p><em>O(min(n,W))</em>. The expression <code>(<code><a href="Data-IntMap.html#v:findWithDefault">findWithDefault</a></code> def k map)</code> returns the value at key <code>k</code> or returns <code>def</code> when the key is not an element of the map. </p><pre> findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x' findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a' </pre></div></div><h1 id="g:4">Construction </h1><div class="top"><p class="src"><a name="v:empty" class="def">empty</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(1)</em>. The empty map. </p><pre> empty == fromList [] size empty == 0 </pre></div></div><div class="top"><p class="src"><a name="v:singleton" class="def">singleton</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(1)</em>. A map of one element. </p><pre> singleton 1 'a' == fromList [(1, 'a')] size (singleton 1 'a') == 1 </pre></div></div><h2 id="g:5">Insertion </h2><div class="top"><p class="src"><a name="v:insert" class="def">insert</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value, i.e. <code><a href="Data-IntMap.html#v:insert">insert</a></code> is equivalent to <code><code><a href="Data-IntMap.html#v:insertWith">insertWith</a></code> <code><a href="../base-4.5.1.0/Prelude.html#v:const">const</a></code></code>. </p><pre> insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')] insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')] insert 5 'x' empty == singleton 5 'x' </pre></div></div><div class="top"><p class="src"><a name="v:insertWith" class="def">insertWith</a> :: (a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. Insert with a combining function. <code><code><a href="Data-IntMap.html#v:insertWith">insertWith</a></code> f key value mp</code> will insert the pair (key, value) into <code>mp</code> if key does not exist in the map. If the key does exist, the function will insert <code>f new_value old_value</code>. </p><pre> insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")] insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWith (++) 5 "xxx" empty == singleton 5 "xxx" </pre></div></div><div class="top"><p class="src"><a name="v:insertWith-39-" class="def">insertWith'</a> :: (a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p>Same as <code><a href="Data-IntMap.html#v:insertWith">insertWith</a></code>, but the combining function is applied strictly. </p></div></div><div class="top"><p class="src"><a name="v:insertWithKey" class="def">insertWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. Insert with a combining function. <code><code><a href="Data-IntMap.html#v:insertWithKey">insertWithKey</a></code> f key value mp</code> will insert the pair (key, value) into <code>mp</code> if key does not exist in the map. If the key does exist, the function will insert <code>f key new_value old_value</code>. </p><pre> let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")] insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWithKey f 5 "xxx" empty == singleton 5 "xxx" </pre></div></div><div class="top"><p class="src"><a name="v:insertWithKey-39-" class="def">insertWithKey'</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p>Same as <code><a href="Data-IntMap.html#v:insertWithKey">insertWithKey</a></code>, but the combining function is applied strictly. </p></div></div><div class="top"><p class="src"><a name="v:insertLookupWithKey" class="def">insertLookupWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(min(n,W))</em>. The expression (<code><code><a href="Data-IntMap.html#v:insertLookupWithKey">insertLookupWithKey</a></code> f k x map</code>) is a pair where the first element is equal to (<code><code><a href="Data-IntMap.html#v:lookup">lookup</a></code> k map</code>) and the second element equal to (<code><code><a href="Data-IntMap.html#v:insertWithKey">insertWithKey</a></code> f k x map</code>). </p><pre> let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")]) insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")]) insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx") </pre><p>This is how to define <code>insertLookup</code> using <code>insertLookupWithKey</code>: </p><pre> let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")]) insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")]) </pre></div></div><h2 id="g:6">Delete/Update </h2><div class="top"><p class="src"><a name="v:delete" class="def">delete</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. Delete a key and its value from the map. When the key is not a member of the map, the original map is returned. </p><pre> delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] delete 5 empty == empty </pre></div></div><div class="top"><p class="src"><a name="v:adjust" class="def">adjust</a> :: (a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. Adjust a value at a specific key. When the key is not a member of the map, the original map is returned. </p><pre> adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjust ("new " ++) 7 empty == empty </pre></div></div><div class="top"><p class="src"><a name="v:adjustWithKey" class="def">adjustWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. Adjust a value at a specific key. When the key is not a member of the map, the original map is returned. </p><pre> let f key x = (show key) ++ ":new " ++ x adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjustWithKey f 7 empty == empty </pre></div></div><div class="top"><p class="src"><a name="v:update" class="def">update</a> :: (a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. The expression (<code><code><a href="Data-IntMap.html#v:update">update</a></code> f k map</code>) updates the value <code>x</code> at <code>k</code> (if it is in the map). If (<code>f x</code>) is <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code>, the element is deleted. If it is (<code><code><a href="../base-4.5.1.0/Data-Maybe.html#v:Just">Just</a></code> y</code>), the key <code>k</code> is bound to the new value <code>y</code>. </p><pre> let f x = if x == "a" then Just "new a" else Nothing update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" </pre></div></div><div class="top"><p class="src"><a name="v:updateWithKey" class="def">updateWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(min(n,W))</em>. The expression (<code><code><a href="Data-IntMap.html#v:update">update</a></code> f k map</code>) updates the value <code>x</code> at <code>k</code> (if it is in the map). If (<code>f k x</code>) is <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code>, the element is deleted. If it is (<code><code><a href="../base-4.5.1.0/Data-Maybe.html#v:Just">Just</a></code> y</code>), the key <code>k</code> is bound to the new value <code>y</code>. </p><pre> let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" </pre></div></div><div class="top"><p class="src"><a name="v:updateLookupWithKey" class="def">updateLookupWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(min(n,W))</em>. Lookup and update. The function returns original value, if it is updated. This is different behavior than <code><a href="Data-Map.html#v:updateLookupWithKey">updateLookupWithKey</a></code>. Returns the original key value if the map entry is deleted. </p><pre> let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:new a")]) updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")]) updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a") </pre></div></div><div class="top"><p class="src"><a name="v:alter" class="def">alter</a> :: (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(log n)</em>. The expression (<code><code><a href="Data-IntMap.html#v:alter">alter</a></code> f k map</code>) alters the value <code>x</code> at <code>k</code>, or absence thereof. <code><a href="Data-IntMap.html#v:alter">alter</a></code> can be used to insert, delete, or update a value in an <code><a href="Data-IntMap.html#t:IntMap">IntMap</a></code>. In short : <code><code><a href="Data-IntMap.html#v:lookup">lookup</a></code> k (<code><a href="Data-IntMap.html#v:alter">alter</a></code> f k m) = f (<code><a href="Data-IntMap.html#v:lookup">lookup</a></code> k m)</code>. </p></div></div><h1 id="g:7">Combine </h1><h2 id="g:8">Union </h2><div class="top"><p class="src"><a name="v:union" class="def">union</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n+m)</em>. The (left-biased) union of two maps. It prefers the first map when duplicate keys are encountered, i.e. (<code><code><a href="Data-IntMap.html#v:union">union</a></code> == <code><a href="Data-IntMap.html#v:unionWith">unionWith</a></code> <code><a href="../base-4.5.1.0/Prelude.html#v:const">const</a></code></code>). </p><pre> union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")] </pre></div></div><div class="top"><p class="src"><a name="v:unionWith" class="def">unionWith</a> :: (a -> a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n+m)</em>. The union with a combining function. </p><pre> unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")] </pre></div></div><div class="top"><p class="src"><a name="v:unionWithKey" class="def">unionWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n+m)</em>. The union with a combining function. </p><pre> let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")] </pre></div></div><div class="top"><p class="src"><a name="v:unions" class="def">unions</a> :: [<a href="Data-IntMap.html#t:IntMap">IntMap</a> a] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p>The union of a list of maps. </p><pre> unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] == fromList [(3, "b"), (5, "a"), (7, "C")] unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])] == fromList [(3, "B3"), (5, "A3"), (7, "C")] </pre></div></div><div class="top"><p class="src"><a name="v:unionsWith" class="def">unionsWith</a> :: (a -> a -> a) -> [<a href="Data-IntMap.html#t:IntMap">IntMap</a> a] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p>The union of a list of maps, with a combining operation. </p><pre> unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")] </pre></div></div><h2 id="g:9">Difference </h2><div class="top"><p class="src"><a name="v:difference" class="def">difference</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n+m)</em>. Difference between two maps (based on keys). </p><pre> difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b" </pre></div></div><div class="top"><p class="src"><a name="v:differenceWith" class="def">differenceWith</a> :: (a -> b -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n+m)</em>. Difference with a combining function. </p><pre> let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")]) == singleton 3 "b:B" </pre></div></div><div class="top"><p class="src"><a name="v:differenceWithKey" class="def">differenceWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> b -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n+m)</em>. Difference with a combining function. When two equal keys are encountered, the combining function is applied to the key and both values. If it returns <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code>, the element is discarded (proper set difference). If it returns (<code><code><a href="../base-4.5.1.0/Data-Maybe.html#v:Just">Just</a></code> y</code>), the element is updated with a new value <code>y</code>. </p><pre> let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")]) == singleton 3 "3:b|B" </pre></div></div><h2 id="g:10">Intersection </h2><div class="top"><p class="src"><a name="v:intersection" class="def">intersection</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n+m)</em>. The (left-biased) intersection of two maps (based on keys). </p><pre> intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a" </pre></div></div><div class="top"><p class="src"><a name="v:intersectionWith" class="def">intersectionWith</a> :: (a -> b -> c) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> c</p><div class="doc"><p><em>O(n+m)</em>. The intersection with a combining function. </p><pre> intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA" </pre></div></div><div class="top"><p class="src"><a name="v:intersectionWithKey" class="def">intersectionWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> b -> c) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> c</p><div class="doc"><p><em>O(n+m)</em>. The intersection with a combining function. </p><pre> let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A" </pre></div></div><h1 id="g:11">Traversal </h1><h2 id="g:12">Map </h2><div class="top"><p class="src"><a name="v:map" class="def">map</a> :: (a -> b) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</p><div class="doc"><p><em>O(n)</em>. Map a function over all values in the map. </p><pre> map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")] </pre></div></div><div class="top"><p class="src"><a name="v:mapWithKey" class="def">mapWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> b) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</p><div class="doc"><p><em>O(n)</em>. Map a function over all values in the map. </p><pre> let f key x = (show key) ++ ":" ++ x mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")] </pre></div></div><div class="top"><p class="src"><a name="v:mapAccum" class="def">mapAccum</a> :: (a -> b -> (a, c)) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</p><div class="doc"><p><em>O(n)</em>. The function <code><code><a href="Data-IntMap.html#v:mapAccum">mapAccum</a></code></code> threads an accumulating argument through the map in ascending order of keys. </p><pre> let f a b = (a ++ b, b ++ "X") mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")]) </pre></div></div><div class="top"><p class="src"><a name="v:mapAccumWithKey" class="def">mapAccumWithKey</a> :: (a -> <a href="Data-IntMap.html#t:Key">Key</a> -> b -> (a, c)) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</p><div class="doc"><p><em>O(n)</em>. The function <code><code><a href="Data-IntMap.html#v:mapAccumWithKey">mapAccumWithKey</a></code></code> threads an accumulating argument through the map in ascending order of keys. </p><pre> let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X") mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")]) </pre></div></div><div class="top"><p class="src"><a name="v:mapAccumRWithKey" class="def">mapAccumRWithKey</a> :: (a -> <a href="Data-IntMap.html#t:Key">Key</a> -> b -> (a, c)) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</p><div class="doc"><p><em>O(n)</em>. The function <code><code>mapAccumR</code></code> threads an accumulating argument through the map in descending order of keys. </p></div></div><h1 id="g:13">Folds </h1><div class="top"><p class="src"><a name="v:foldr" class="def">foldr</a> :: (a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</p><div class="doc"><p><em>O(n)</em>. Fold the values in the map using the given right-associative binary operator, such that <code><code><a href="Data-IntMap.html#v:foldr">foldr</a></code> f z == <code><a href="../base-4.5.1.0/Prelude.html#v:foldr">foldr</a></code> f z . <code><a href="Data-IntMap.html#v:elems">elems</a></code></code>. </p><p>For example, </p><pre> elems map = foldr (:) [] map </pre><pre> let f a len = len + (length a) foldr f 0 (fromList [(5,"a"), (3,"bbb")]) == 4 </pre></div></div><div class="top"><p class="src"><a name="v:foldl" class="def">foldl</a> :: (a -> b -> a) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> a</p><div class="doc"><p><em>O(n)</em>. Fold the values in the map using the given left-associative binary operator, such that <code><code><a href="Data-IntMap.html#v:foldl">foldl</a></code> f z == <code><a href="../base-4.5.1.0/Prelude.html#v:foldl">foldl</a></code> f z . <code><a href="Data-IntMap.html#v:elems">elems</a></code></code>. </p><p>For example, </p><pre> elems = reverse . foldl (flip (:)) [] </pre><pre> let f len a = len + (length a) foldl f 0 (fromList [(5,"a"), (3,"bbb")]) == 4 </pre></div></div><div class="top"><p class="src"><a name="v:foldrWithKey" class="def">foldrWithKey</a> :: (<a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</p><div class="doc"><p><em>O(n)</em>. Fold the keys and values in the map using the given right-associative binary operator, such that <code><code><a href="Data-IntMap.html#v:foldrWithKey">foldrWithKey</a></code> f z == <code><a href="../base-4.5.1.0/Prelude.html#v:foldr">foldr</a></code> (<code><a href="../base-4.5.1.0/Data-Tuple.html#v:uncurry">uncurry</a></code> f) z . <code><a href="Data-IntMap.html#v:toAscList">toAscList</a></code></code>. </p><p>For example, </p><pre> keys map = foldrWithKey (\k x ks -> k:ks) [] map </pre><pre> let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)" </pre></div></div><div class="top"><p class="src"><a name="v:foldlWithKey" class="def">foldlWithKey</a> :: (a -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> b -> a) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> a</p><div class="doc"><p><em>O(n)</em>. Fold the keys and values in the map using the given left-associative binary operator, such that <code><code><a href="Data-IntMap.html#v:foldlWithKey">foldlWithKey</a></code> f z == <code><a href="../base-4.5.1.0/Prelude.html#v:foldl">foldl</a></code> (\z' (kx, x) -> f z' kx x) z . <code><a href="Data-IntMap.html#v:toAscList">toAscList</a></code></code>. </p><p>For example, </p><pre> keys = reverse . foldlWithKey (\ks k x -> k:ks) [] </pre><pre> let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)" </pre></div></div><h2 id="g:14">Strict folds </h2><div class="top"><p class="src"><a name="v:foldr-39-" class="def">foldr'</a> :: (a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</p><div class="doc"><p><em>O(n)</em>. A strict version of <code><a href="Data-IntMap.html#v:foldr">foldr</a></code>. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value. </p></div></div><div class="top"><p class="src"><a name="v:foldl-39-" class="def">foldl'</a> :: (a -> b -> a) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> a</p><div class="doc"><p><em>O(n)</em>. A strict version of <code><a href="Data-IntMap.html#v:foldl">foldl</a></code>. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value. </p></div></div><div class="top"><p class="src"><a name="v:foldrWithKey-39-" class="def">foldrWithKey'</a> :: (<a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</p><div class="doc"><p><em>O(n)</em>. A strict version of <code><a href="Data-IntMap.html#v:foldrWithKey">foldrWithKey</a></code>. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value. </p></div></div><div class="top"><p class="src"><a name="v:foldlWithKey-39-" class="def">foldlWithKey'</a> :: (a -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> b -> a) -> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> a</p><div class="doc"><p><em>O(n)</em>. A strict version of <code><a href="Data-IntMap.html#v:foldlWithKey">foldlWithKey</a></code>. Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value. </p></div></div><h2 id="g:15">Legacy folds </h2><div class="top"><p class="src"><a name="v:fold" class="def">fold</a> :: (a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</p><div class="doc"><p><em>O(n)</em>. Fold the values in the map using the given right-associative binary operator. This function is an equivalent of <code><a href="Data-IntMap.html#v:foldr">foldr</a></code> and is present for compatibility only. </p><p><em>Please note that fold will be deprecated in the future and removed.</em> </p></div></div><div class="top"><p class="src"><a name="v:foldWithKey" class="def">foldWithKey</a> :: (<a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> a -> b -> b) -> b -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> b</p><div class="doc"><p><em>O(n)</em>. Fold the keys and values in the map using the given right-associative binary operator. This function is an equivalent of <code><a href="Data-IntMap.html#v:foldrWithKey">foldrWithKey</a></code> and is present for compatibility only. </p><p><em>Please note that foldWithKey will be deprecated in the future and removed.</em> </p></div></div><h1 id="g:16">Conversion </h1><div class="top"><p class="src"><a name="v:elems" class="def">elems</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [a]</p><div class="doc"><p><em>O(n)</em>. Return all elements of the map in the ascending order of their keys. </p><pre> elems (fromList [(5,"a"), (3,"b")]) == ["b","a"] elems empty == [] </pre></div></div><div class="top"><p class="src"><a name="v:keys" class="def">keys</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [<a href="Data-IntMap.html#t:Key">Key</a>]</p><div class="doc"><p><em>O(n)</em>. Return all keys of the map in ascending order. </p><pre> keys (fromList [(5,"a"), (3,"b")]) == [3,5] keys empty == [] </pre></div></div><div class="top"><p class="src"><a name="v:keysSet" class="def">keysSet</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntSet.html#t:IntSet">IntSet</a></p><div class="doc"><p><em>O(n*min(n,W))</em>. The set of all keys of the map. </p><pre> keysSet (fromList [(5,"a"), (3,"b")]) == Data.IntSet.fromList [3,5] keysSet empty == Data.IntSet.empty </pre></div></div><div class="top"><p class="src"><a name="v:assocs" class="def">assocs</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)]</p><div class="doc"><p><em>O(n)</em>. Return all key/value pairs in the map in ascending key order. </p><pre> assocs (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")] assocs empty == [] </pre></div></div><h2 id="g:17">Lists </h2><div class="top"><p class="src"><a name="v:toList" class="def">toList</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)]</p><div class="doc"><p><em>O(n)</em>. Convert the map to a list of key/value pairs. </p><pre> toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")] toList empty == [] </pre></div></div><div class="top"><p class="src"><a name="v:fromList" class="def">fromList</a> :: [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n*min(n,W))</em>. Create a map from a list of key/value pairs. </p><pre> fromList [] == empty fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")] fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")] </pre></div></div><div class="top"><p class="src"><a name="v:fromListWith" class="def">fromListWith</a> :: (a -> a -> a) -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n*min(n,W))</em>. Create a map from a list of key/value pairs with a combining function. See also <code><a href="Data-IntMap.html#v:fromAscListWith">fromAscListWith</a></code>. </p><pre> fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "ab"), (5, "cba")] fromListWith (++) [] == empty </pre></div></div><div class="top"><p class="src"><a name="v:fromListWithKey" class="def">fromListWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n*min(n,W))</em>. Build a map from a list of key/value pairs with a combining function. See also fromAscListWithKey'. </p><pre> let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")] fromListWithKey f [] == empty </pre></div></div><h2 id="g:18">Ordered lists </h2><div class="top"><p class="src"><a name="v:toAscList" class="def">toAscList</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)]</p><div class="doc"><p><em>O(n)</em>. Convert the map to a list of key/value pairs where the keys are in ascending order. </p><pre> toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")] </pre></div></div><div class="top"><p class="src"><a name="v:fromAscList" class="def">fromAscList</a> :: [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n)</em>. Build a map from a list of key/value pairs where the keys are in ascending order. </p><pre> fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")] </pre></div></div><div class="top"><p class="src"><a name="v:fromAscListWith" class="def">fromAscListWith</a> :: (a -> a -> a) -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n)</em>. Build a map from a list of key/value pairs where the keys are in ascending order, with a combining function on equal keys. <em>The precondition (input list is ascending) is not checked.</em> </p><pre> fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")] </pre></div></div><div class="top"><p class="src"><a name="v:fromAscListWithKey" class="def">fromAscListWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a -> a) -> [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n)</em>. Build a map from a list of key/value pairs where the keys are in ascending order, with a combining function on equal keys. <em>The precondition (input list is ascending) is not checked.</em> </p><pre> let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "5:b|a")] </pre></div></div><div class="top"><p class="src"><a name="v:fromDistinctAscList" class="def">fromDistinctAscList</a> :: <span class="keyword">forall</span> a. [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n)</em>. Build a map from a list of key/value pairs where the keys are in ascending order and all distinct. <em>The precondition (input list is strictly ascending) is not checked.</em> </p><pre> fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] </pre></div></div><h1 id="g:19">Filter </h1><div class="top"><p class="src"><a name="v:filter" class="def">filter</a> :: (a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n)</em>. Filter all values that satisfy some predicate. </p><pre> filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty </pre></div></div><div class="top"><p class="src"><a name="v:filterWithKey" class="def">filterWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(n)</em>. Filter all keys/values that satisfy some predicate. </p><pre> filterWithKey (\k _ -> k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" </pre></div></div><div class="top"><p class="src"><a name="v:partition" class="def">partition</a> :: (a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(n)</em>. Partition the map according to some predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also <code><a href="Data-IntMap.html#v:split">split</a></code>. </p><pre> partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a") partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty) partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")]) </pre></div></div><div class="top"><p class="src"><a name="v:partitionWithKey" class="def">partitionWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(n)</em>. Partition the map according to some predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also <code><a href="Data-IntMap.html#v:split">split</a></code>. </p><pre> partitionWithKey (\ k _ -> k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b") partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty) partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")]) </pre></div></div><div class="top"><p class="src"><a name="v:mapMaybe" class="def">mapMaybe</a> :: (a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> b) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</p><div class="doc"><p><em>O(n)</em>. Map values and collect the <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Just">Just</a></code> results. </p><pre> let f x = if x == "a" then Just "new a" else Nothing mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a" </pre></div></div><div class="top"><p class="src"><a name="v:mapMaybeWithKey" class="def">mapMaybeWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> b) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</p><div class="doc"><p><em>O(n)</em>. Map keys/values and collect the <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Just">Just</a></code> results. </p><pre> let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3" </pre></div></div><div class="top"><p class="src"><a name="v:mapEither" class="def">mapEither</a> :: (a -> <a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> b c) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> b, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</p><div class="doc"><p><em>O(n)</em>. Map values and separate the <code><a href="../base-4.5.1.0/Data-Either.html#v:Left">Left</a></code> and <code><a href="../base-4.5.1.0/Data-Either.html#v:Right">Right</a></code> results. </p><pre> let f a = if a < "c" then Left a else Right a mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")]) mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) </pre></div></div><div class="top"><p class="src"><a name="v:mapEitherWithKey" class="def">mapEitherWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> <a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> b c) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> b, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</p><div class="doc"><p><em>O(n)</em>. Map keys/values and separate the <code><a href="../base-4.5.1.0/Data-Either.html#v:Left">Left</a></code> and <code><a href="../base-4.5.1.0/Data-Either.html#v:Right">Right</a></code> results. </p><pre> let f k a = if k < 5 then Left (k * 2) else Right (a ++ a) mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")]) mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")]) </pre></div></div><div class="top"><p class="src"><a name="v:split" class="def">split</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(log n)</em>. The expression (<code><code><a href="Data-IntMap.html#v:split">split</a></code> k map</code>) is a pair <code>(map1,map2)</code> where all keys in <code>map1</code> are lower than <code>k</code> and all keys in <code>map2</code> larger than <code>k</code>. Any key equal to <code>k</code> is found in neither <code>map1</code> nor <code>map2</code>. </p><pre> split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")]) split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a") split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a") split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty) split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty) </pre></div></div><div class="top"><p class="src"><a name="v:splitLookup" class="def">splitLookup</a> :: <a href="Data-IntMap.html#t:Key">Key</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:IntMap">IntMap</a> a, <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(log n)</em>. Performs a <code><a href="Data-IntMap.html#v:split">split</a></code> but also returns whether the pivot key was found in the original map. </p><pre> splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")]) splitLookup 3 (fromList [(5,"a"), (3,"b")]) == (empty, Just "b", singleton 5 "a") splitLookup 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Nothing, singleton 5 "a") splitLookup 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Just "a", empty) splitLookup 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], Nothing, empty) </pre></div></div><h1 id="g:20">Submap </h1><div class="top"><p class="src"><a name="v:isSubmapOf" class="def">isSubmapOf</a> :: <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> a => <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><em>O(n+m)</em>. Is this a submap? Defined as (<code><code><a href="Data-IntMap.html#v:isSubmapOf">isSubmapOf</a></code> = <code><a href="Data-IntMap.html#v:isSubmapOfBy">isSubmapOfBy</a></code> (==)</code>). </p></div></div><div class="top"><p class="src"><a name="v:isSubmapOfBy" class="def">isSubmapOfBy</a> :: (a -> b -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><em>O(n+m)</em>. The expression (<code><code><a href="Data-IntMap.html#v:isSubmapOfBy">isSubmapOfBy</a></code> f m1 m2</code>) returns <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code> if all keys in <code>m1</code> are in <code>m2</code>, and when <code>f</code> returns <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code> when applied to their respective values. For example, the following expressions are all <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code>: </p><pre> isSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)]) </pre><p>But the following are all <code><a href="../base-4.5.1.0/Data-Bool.html#v:False">False</a></code>: </p><pre> isSubmapOfBy (==) (fromList [(1,2)]) (fromList [(1,1),(2,2)]) isSubmapOfBy (<) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)]) </pre></div></div><div class="top"><p class="src"><a name="v:isProperSubmapOf" class="def">isProperSubmapOf</a> :: <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> a => <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><em>O(n+m)</em>. Is this a proper submap? (ie. a submap but not equal). Defined as (<code><code><a href="Data-IntMap.html#v:isProperSubmapOf">isProperSubmapOf</a></code> = <code><a href="Data-IntMap.html#v:isProperSubmapOfBy">isProperSubmapOfBy</a></code> (==)</code>). </p></div></div><div class="top"><p class="src"><a name="v:isProperSubmapOfBy" class="def">isProperSubmapOfBy</a> :: (a -> b -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><em>O(n+m)</em>. Is this a proper submap? (ie. a submap but not equal). The expression (<code><code><a href="Data-IntMap.html#v:isProperSubmapOfBy">isProperSubmapOfBy</a></code> f m1 m2</code>) returns <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code> when <code>m1</code> and <code>m2</code> are not equal, all keys in <code>m1</code> are in <code>m2</code>, and when <code>f</code> returns <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code> when applied to their respective values. For example, the following expressions are all <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code>: </p><pre> isProperSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isProperSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) </pre><p>But the following are all <code><a href="../base-4.5.1.0/Data-Bool.html#v:False">False</a></code>: </p><pre> isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)]) isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)]) isProperSubmapOfBy (<) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) </pre></div></div><h1 id="g:21">Min/Max </h1><div class="top"><p class="src"><a name="v:findMin" class="def">findMin</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:Key">Key</a>, a)</p><div class="doc"><p><em>O(log n)</em>. The minimal key of the map. </p></div></div><div class="top"><p class="src"><a name="v:findMax" class="def">findMax</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (<a href="Data-IntMap.html#t:Key">Key</a>, a)</p><div class="doc"><p><em>O(log n)</em>. The maximal key of the map. </p></div></div><div class="top"><p class="src"><a name="v:deleteMin" class="def">deleteMin</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(log n)</em>. Delete the minimal key. An error is thrown if the IntMap is already empty. Note, this is not the same behavior Map. </p></div></div><div class="top"><p class="src"><a name="v:deleteMax" class="def">deleteMax</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(log n)</em>. Delete the maximal key. An error is thrown if the IntMap is already empty. Note, this is not the same behavior Map. </p></div></div><div class="top"><p class="src"><a name="v:deleteFindMin" class="def">deleteFindMin</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(log n)</em>. Delete and find the minimal element. </p></div></div><div class="top"><p class="src"><a name="v:deleteFindMax" class="def">deleteFindMax</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(log n)</em>. Delete and find the maximal element. </p></div></div><div class="top"><p class="src"><a name="v:updateMin" class="def">updateMin</a> :: (a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(log n)</em>. Update the value at the minimal key. </p><pre> updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")] updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" </pre></div></div><div class="top"><p class="src"><a name="v:updateMax" class="def">updateMax</a> :: (a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(log n)</em>. Update the value at the maximal key. </p><pre> updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")] updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" </pre></div></div><div class="top"><p class="src"><a name="v:updateMinWithKey" class="def">updateMinWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(log n)</em>. Update the value at the minimal key. </p><pre> updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")] updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" </pre></div></div><div class="top"><p class="src"><a name="v:updateMaxWithKey" class="def">updateMaxWithKey</a> :: (<a href="Data-IntMap.html#t:Key">Key</a> -> a -> a) -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</p><div class="doc"><p><em>O(log n)</em>. Update the value at the maximal key. </p><pre> updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")] updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" </pre></div></div><div class="top"><p class="src"><a name="v:minView" class="def">minView</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(log n)</em>. Retrieves the minimal key of the map, and the map stripped of that element, or <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code> if passed an empty map. </p></div></div><div class="top"><p class="src"><a name="v:maxView" class="def">maxView</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(log n)</em>. Retrieves the maximal key of the map, and the map stripped of that element, or <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code> if passed an empty map. </p></div></div><div class="top"><p class="src"><a name="v:minViewWithKey" class="def">minViewWithKey</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> ((<a href="Data-IntMap.html#t:Key">Key</a>, a), <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(log n)</em>. Retrieves the minimal (key,value) pair of the map, and the map stripped of that element, or <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code> if passed an empty map. </p><pre> minViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((3,"b"), singleton 5 "a") minViewWithKey empty == Nothing </pre></div></div><div class="top"><p class="src"><a name="v:maxViewWithKey" class="def">maxViewWithKey</a> :: <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> ((<a href="Data-IntMap.html#t:Key">Key</a>, a), <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</p><div class="doc"><p><em>O(log n)</em>. Retrieves the maximal (key,value) pair of the map, and the map stripped of that element, or <code><a href="../base-4.5.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code> if passed an empty map. </p><pre> maxViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((5,"a"), singleton 3 "b") maxViewWithKey empty == Nothing </pre></div></div><h1 id="g:22">Debugging </h1><div class="top"><p class="src"><a name="v:showTree" class="def">showTree</a> :: <a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> a => <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p><div class="doc"><p><em>O(n)</em>. Show the tree that implements the map. The tree is shown in a compressed, hanging format. </p></div></div><div class="top"><p class="src"><a name="v:showTreeWith" class="def">showTreeWith</a> :: <a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> a => <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p><div class="doc"><p><em>O(n)</em>. The expression (<code><code><a href="Data-IntMap.html#v:showTreeWith">showTreeWith</a></code> hang wide map</code>) shows the tree that implements the map. If <code>hang</code> is <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code>, a <em>hanging</em> tree is shown otherwise a rotated tree is shown. If <code>wide</code> is <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code>, an extra wide version is shown. </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>