Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 6e204a966e8c42d976f99a1700ce5f20 > files > 2590

ghc-7.4.2-4.mga5.i586.rpm

<!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,  &quot;<em>Fast Mergeable Integer Maps</em>&quot;,
      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, &quot;/PATRICIA -- Practical Algorithm To Retrieve
      Information Coded In Alphanumeric/&quot;, 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 -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a</li><li class="src short"><a href="#v:-92--92-">(\\)</a> ::  <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 -&gt; <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 -&gt; <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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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> -&gt; a -&gt; <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> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:insertWith">insertWith</a> ::  (a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:insertWith-39-">insertWith'</a> ::  (a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:adjust">adjust</a> ::  (a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:update">update</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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 -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:unionWith">unionWith</a> ::  (a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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] -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:unionsWith">unionsWith</a> ::  (a -&gt; a -&gt; a) -&gt; [<a href="Data-IntMap.html#t:IntMap">IntMap</a> a] -&gt; <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 -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:differenceWith">differenceWith</a> ::  (a -&gt; b -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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> -&gt; a -&gt; b -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:intersectionWith">intersectionWith</a> ::  (a -&gt; b -&gt; c) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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> -&gt; a -&gt; b -&gt; c) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> c</li><li class="src short"><a href="#v:map">map</a> ::  (a -&gt; b) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; b) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</li><li class="src short"><a href="#v:mapAccum">mapAccum</a> ::  (a -&gt; b -&gt; (a, c)) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</li><li class="src short"><a href="#v:mapAccumWithKey">mapAccumWithKey</a> ::  (a -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; b -&gt; (a, c)) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</li><li class="src short"><a href="#v:mapAccumRWithKey">mapAccumRWithKey</a> ::  (a -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; b -&gt; (a, c)) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> c)</li><li class="src short"><a href="#v:foldr">foldr</a> ::  (a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; b</li><li class="src short"><a href="#v:foldl">foldl</a> ::  (a -&gt; b -&gt; a) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; 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> -&gt; a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; b</li><li class="src short"><a href="#v:foldlWithKey">foldlWithKey</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -&gt; b -&gt; a) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; a</li><li class="src short"><a href="#v:foldr-39-">foldr'</a> ::  (a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; b</li><li class="src short"><a href="#v:foldl-39-">foldl'</a> ::  (a -&gt; b -&gt; a) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; 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> -&gt; a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; b</li><li class="src short"><a href="#v:foldlWithKey-39-">foldlWithKey'</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -&gt; b -&gt; a) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; a</li><li class="src short"><a href="#v:fold">fold</a> ::  (a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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> -&gt; a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; b</li><li class="src short"><a href="#v:elems">elems</a> ::  <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; [a]</li><li class="src short"><a href="#v:keys">keys</a> ::  <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; [<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 -&gt; <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 -&gt; [(<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 -&gt; [(<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)] -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:fromListWith">fromListWith</a> ::  (a -&gt; a -&gt; a) -&gt; [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -&gt; <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> -&gt; a -&gt; a -&gt; a) -&gt; [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -&gt; <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 -&gt; [(<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)] -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:fromAscListWith">fromAscListWith</a> ::  (a -&gt; a -&gt; a) -&gt; [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -&gt; <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> -&gt; a -&gt; a -&gt; a) -&gt; [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -&gt; <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)] -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:filter">filter</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:partition">partition</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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 -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> b) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> b) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b</li><li class="src short"><a href="#v:mapEither">mapEither</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> b c) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> b c) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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 =&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 =&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 -&gt; (<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 -&gt; (<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 -&gt; <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 -&gt; <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 -&gt; (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 -&gt; (a, <a href="Data-IntMap.html#t:IntMap">IntMap</a> a)</li><li class="src short"><a href="#v:updateMin">updateMin</a> ::  (a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a</li><li class="src short"><a href="#v:updateMax">updateMax</a> ::  (a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; <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 -&gt; <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 -&gt; <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 -&gt; <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 =&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 =&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; <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">&nbsp;</td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Data.html#t:Data">Data</a> a =&gt; <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">&nbsp;</td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Ord.html#t:Ord">Ord</a> a =&gt; <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">&nbsp;</td></tr><tr><td class="src"><a href="../base-4.5.1.0/Text-Read.html#t:Read">Read</a> e =&gt; <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">&nbsp;</td></tr><tr><td class="src"><a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> a =&gt; <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">&nbsp;</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">&nbsp;</td></tr><tr><td class="src"><a href="../deepseq-1.3.0.0/Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; <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">&nbsp;</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 -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; 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 -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 -&gt; <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 -&gt; <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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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> -&gt; a -&gt; <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> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 &quot;xxx&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;xxxa&quot;)]
 insertWith (++) 7 &quot;xxx&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;), (7, &quot;xxx&quot;)]
 insertWith (++) 5 &quot;xxx&quot; empty                         == singleton 5 &quot;xxx&quot;
</pre></div></div><div class="top"><p class="src"><a name="v:insertWith-39-" class="def">insertWith'</a> ::  (a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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) ++ &quot;:&quot; ++ new_value ++ &quot;|&quot; ++ old_value
 insertWithKey f 5 &quot;xxx&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;5:xxx|a&quot;)]
 insertWithKey f 7 &quot;xxx&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;), (7, &quot;xxx&quot;)]
 insertWithKey f 5 &quot;xxx&quot; empty                         == singleton 5 &quot;xxx&quot;
</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> -&gt; a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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> -&gt; a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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) ++ &quot;:&quot; ++ new_value ++ &quot;|&quot; ++ old_value
 insertLookupWithKey f 5 &quot;xxx&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (Just &quot;a&quot;, fromList [(3, &quot;b&quot;), (5, &quot;5:xxx|a&quot;)])
 insertLookupWithKey f 7 &quot;xxx&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (Nothing,  fromList [(3, &quot;b&quot;), (5, &quot;a&quot;), (7, &quot;xxx&quot;)])
 insertLookupWithKey f 5 &quot;xxx&quot; empty                         == (Nothing,  singleton 5 &quot;xxx&quot;)
</pre><p>This is how to define <code>insertLookup</code> using <code>insertLookupWithKey</code>:
</p><pre> let insertLookup kx x t = insertLookupWithKey (\_ a _ -&gt; a) kx x t
 insertLookup 5 &quot;x&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (Just &quot;a&quot;, fromList [(3, &quot;b&quot;), (5, &quot;x&quot;)])
 insertLookup 7 &quot;x&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (Nothing,  fromList [(3, &quot;b&quot;), (5, &quot;a&quot;), (7, &quot;x&quot;)])
</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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 3 &quot;b&quot;
 delete 7 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)]
 delete 5 empty                         == empty
</pre></div></div><div class="top"><p class="src"><a name="v:adjust" class="def">adjust</a> ::  (a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 (&quot;new &quot; ++) 5 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;new a&quot;)]
 adjust (&quot;new &quot; ++) 7 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)]
 adjust (&quot;new &quot; ++) 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> -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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) ++ &quot;:new &quot; ++ x
 adjustWithKey f 5 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;5:new a&quot;)]
 adjustWithKey f 7 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)]
 adjustWithKey f 7 empty                         == empty
</pre></div></div><div class="top"><p class="src"><a name="v:update" class="def">update</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 == &quot;a&quot; then Just &quot;new a&quot; else Nothing
 update f 5 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;new a&quot;)]
 update f 7 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)]
 update f 3 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 5 &quot;a&quot;
</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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 == &quot;a&quot; then Just ((show k) ++ &quot;:new a&quot;) else Nothing
 updateWithKey f 5 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;5:new a&quot;)]
 updateWithKey f 7 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)]
 updateWithKey f 3 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 5 &quot;a&quot;
</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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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 == &quot;a&quot; then Just ((show k) ++ &quot;:new a&quot;) else Nothing
 updateLookupWithKey f 5 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (Just &quot;a&quot;, fromList [(3, &quot;b&quot;), (5, &quot;5:new a&quot;)])
 updateLookupWithKey f 7 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (Nothing,  fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)])
 updateLookupWithKey f 3 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (Just &quot;b&quot;, singleton 5 &quot;a&quot;)
</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 -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;), (7, &quot;C&quot;)]
</pre></div></div><div class="top"><p class="src"><a name="v:unionWith" class="def">unionWith</a> ::  (a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;aA&quot;), (7, &quot;C&quot;)]
</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> -&gt; a -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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) ++ &quot;:&quot; ++ left_value ++ &quot;|&quot; ++ right_value
 unionWithKey f (fromList [(5, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;5:a|A&quot;), (7, &quot;C&quot;)]
</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] -&gt; <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, &quot;a&quot;), (3, &quot;b&quot;)]), (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]), (fromList [(5, &quot;A3&quot;), (3, &quot;B3&quot;)])]
     == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;), (7, &quot;C&quot;)]
 unions [(fromList [(5, &quot;A3&quot;), (3, &quot;B3&quot;)]), (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]), (fromList [(5, &quot;a&quot;), (3, &quot;b&quot;)])]
     == fromList [(3, &quot;B3&quot;), (5, &quot;A3&quot;), (7, &quot;C&quot;)]
</pre></div></div><div class="top"><p class="src"><a name="v:unionsWith" class="def">unionsWith</a> ::  (a -&gt; a -&gt; a) -&gt; [<a href="Data-IntMap.html#t:IntMap">IntMap</a> a] -&gt; <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, &quot;a&quot;), (3, &quot;b&quot;)]), (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]), (fromList [(5, &quot;A3&quot;), (3, &quot;B3&quot;)])]
     == fromList [(3, &quot;bB3&quot;), (5, &quot;aAA3&quot;), (7, &quot;C&quot;)]
</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 -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]) == singleton 3 &quot;b&quot;
</pre></div></div><div class="top"><p class="src"><a name="v:differenceWith" class="def">differenceWith</a> ::  (a -&gt; b -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 == &quot;b&quot; then Just (al ++ &quot;:&quot; ++ ar) else Nothing
 differenceWith f (fromList [(5, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (3, &quot;B&quot;), (7, &quot;C&quot;)])
     == singleton 3 &quot;b:B&quot;
</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> -&gt; a -&gt; b -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 == &quot;b&quot; then Just ((show k) ++ &quot;:&quot; ++ al ++ &quot;|&quot; ++ ar) else Nothing
 differenceWithKey f (fromList [(5, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (3, &quot;B&quot;), (10, &quot;C&quot;)])
     == singleton 3 &quot;3:b|B&quot;
</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 -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]) == singleton 5 &quot;a&quot;
</pre></div></div><div class="top"><p class="src"><a name="v:intersectionWith" class="def">intersectionWith</a> ::  (a -&gt; b -&gt; c) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]) == singleton 5 &quot;aA&quot;
</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> -&gt; a -&gt; b -&gt; c) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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) ++ &quot;:&quot; ++ al ++ &quot;|&quot; ++ ar
 intersectionWithKey f (fromList [(5, &quot;a&quot;), (3, &quot;b&quot;)]) (fromList [(5, &quot;A&quot;), (7, &quot;C&quot;)]) == singleton 5 &quot;5:a|A&quot;
</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 -&gt; b) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 (++ &quot;x&quot;) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;bx&quot;), (5, &quot;ax&quot;)]
</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> -&gt; a -&gt; b) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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) ++ &quot;:&quot; ++ x
 mapWithKey f (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;3:b&quot;), (5, &quot;5:a&quot;)]
</pre></div></div><div class="top"><p class="src"><a name="v:mapAccum" class="def">mapAccum</a> ::  (a -&gt; b -&gt; (a, c)) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; (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 ++ &quot;X&quot;)
 mapAccum f &quot;Everything: &quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (&quot;Everything: ba&quot;, fromList [(3, &quot;bX&quot;), (5, &quot;aX&quot;)])
</pre></div></div><div class="top"><p class="src"><a name="v:mapAccumWithKey" class="def">mapAccumWithKey</a> ::  (a -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; b -&gt; (a, c)) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; (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 ++ &quot; &quot; ++ (show k) ++ &quot;-&quot; ++ b, b ++ &quot;X&quot;)
 mapAccumWithKey f &quot;Everything:&quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (&quot;Everything: 3-b 5-a&quot;, fromList [(3, &quot;bX&quot;), (5, &quot;aX&quot;)])
</pre></div></div><div class="top"><p class="src"><a name="v:mapAccumRWithKey" class="def">mapAccumRWithKey</a> ::  (a -&gt; <a href="Data-IntMap.html#t:Key">Key</a> -&gt; b -&gt; (a, c)) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; (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 -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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,&quot;a&quot;), (3,&quot;bbb&quot;)]) == 4
</pre></div></div><div class="top"><p class="src"><a name="v:foldl" class="def">foldl</a> ::  (a -&gt; b -&gt; a) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; 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,&quot;a&quot;), (3,&quot;bbb&quot;)]) == 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> -&gt; a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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 -&gt; k:ks) [] map
</pre><pre> let f k a result = result ++ &quot;(&quot; ++ (show k) ++ &quot;:&quot; ++ a ++ &quot;)&quot;
 foldrWithKey f &quot;Map: &quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == &quot;Map: (5:a)(3:b)&quot;
</pre></div></div><div class="top"><p class="src"><a name="v:foldlWithKey" class="def">foldlWithKey</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -&gt; b -&gt; a) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; 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) -&gt; 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 -&gt; k:ks) []
</pre><pre> let f result k a = result ++ &quot;(&quot; ++ (show k) ++ &quot;:&quot; ++ a ++ &quot;)&quot;
 foldlWithKey f &quot;Map: &quot; (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == &quot;Map: (3:b)(5:a)&quot;
</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 -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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 -&gt; b -&gt; a) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; 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> -&gt; a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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 -&gt; <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -&gt; b -&gt; a) -&gt; a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; 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 -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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> -&gt; a -&gt; b -&gt; b) -&gt; b -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; 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 -&gt; [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,&quot;a&quot;), (3,&quot;b&quot;)]) == [&quot;b&quot;,&quot;a&quot;]
 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 -&gt; [<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,&quot;a&quot;), (3,&quot;b&quot;)]) == [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 -&gt; <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,&quot;a&quot;), (3,&quot;b&quot;)]) == 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 -&gt; [(<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,&quot;a&quot;), (3,&quot;b&quot;)]) == [(3,&quot;b&quot;), (5,&quot;a&quot;)]
 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 -&gt; [(<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,&quot;a&quot;), (3,&quot;b&quot;)]) == [(3,&quot;b&quot;), (5,&quot;a&quot;)]
 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)] -&gt; <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,&quot;a&quot;), (3,&quot;b&quot;), (5, &quot;c&quot;)] == fromList [(5,&quot;c&quot;), (3,&quot;b&quot;)]
 fromList [(5,&quot;c&quot;), (3,&quot;b&quot;), (5, &quot;a&quot;)] == fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]
</pre></div></div><div class="top"><p class="src"><a name="v:fromListWith" class="def">fromListWith</a> ::  (a -&gt; a -&gt; a) -&gt; [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -&gt; <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,&quot;a&quot;), (5,&quot;b&quot;), (3,&quot;b&quot;), (3,&quot;a&quot;), (5,&quot;c&quot;)] == fromList [(3, &quot;ab&quot;), (5, &quot;cba&quot;)]
 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> -&gt; a -&gt; a -&gt; a) -&gt; [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -&gt; <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) ++ &quot;:&quot; ++ new_value ++ &quot;|&quot; ++ old_value
 fromListWithKey f [(5,&quot;a&quot;), (5,&quot;b&quot;), (3,&quot;b&quot;), (3,&quot;a&quot;), (5,&quot;c&quot;)] == fromList [(3, &quot;3:a|b&quot;), (5, &quot;5:c|5:b|a&quot;)]
 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 -&gt; [(<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,&quot;a&quot;), (3,&quot;b&quot;)]) == [(3,&quot;b&quot;), (5,&quot;a&quot;)]
</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)] -&gt; <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,&quot;b&quot;), (5,&quot;a&quot;)]          == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)]
 fromAscList [(3,&quot;b&quot;), (5,&quot;a&quot;), (5,&quot;b&quot;)] == fromList [(3, &quot;b&quot;), (5, &quot;b&quot;)]
</pre></div></div><div class="top"><p class="src"><a name="v:fromAscListWith" class="def">fromAscListWith</a> ::  (a -&gt; a -&gt; a) -&gt; [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -&gt; <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,&quot;b&quot;), (5,&quot;a&quot;), (5,&quot;b&quot;)] == fromList [(3, &quot;b&quot;), (5, &quot;ba&quot;)]
</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> -&gt; a -&gt; a -&gt; a) -&gt; [(<a href="Data-IntMap.html#t:Key">Key</a>, a)] -&gt; <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) ++ &quot;:&quot; ++ new_value ++ &quot;|&quot; ++ old_value
 fromAscListWithKey f [(3,&quot;b&quot;), (5,&quot;a&quot;), (5,&quot;b&quot;)] == fromList [(3, &quot;b&quot;), (5, &quot;5:b|a&quot;)]
</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)] -&gt; <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,&quot;b&quot;), (5,&quot;a&quot;)] == fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)]
</pre></div></div><h1 id="g:19">Filter
</h1><div class="top"><p class="src"><a name="v:filter" class="def">filter</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 (&gt; &quot;a&quot;) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 3 &quot;b&quot;
 filter (&gt; &quot;x&quot;) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == empty
 filter (&lt; &quot;a&quot;) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == 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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 _ -&gt; k &gt; 4) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 5 &quot;a&quot;
</pre></div></div><div class="top"><p class="src"><a name="v:partition" class="def">partition</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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 (&gt; &quot;a&quot;) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (singleton 3 &quot;b&quot;, singleton 5 &quot;a&quot;)
 partition (&lt; &quot;x&quot;) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)], empty)
 partition (&gt; &quot;x&quot;) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (empty, fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)])
</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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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 _ -&gt; k &gt; 3) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (singleton 5 &quot;a&quot;, singleton 3 &quot;b&quot;)
 partitionWithKey (\ k _ -&gt; k &lt; 7) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)], empty)
 partitionWithKey (\ k _ -&gt; k &gt; 7) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (empty, fromList [(3, &quot;b&quot;), (5, &quot;a&quot;)])
</pre></div></div><div class="top"><p class="src"><a name="v:mapMaybe" class="def">mapMaybe</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> b) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 == &quot;a&quot; then Just &quot;new a&quot; else Nothing
 mapMaybe f (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 5 &quot;new a&quot;
</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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> b) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 &lt; 5 then Just (&quot;key : &quot; ++ (show k)) else Nothing
 mapMaybeWithKey f (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 3 &quot;key : 3&quot;
</pre></div></div><div class="top"><p class="src"><a name="v:mapEither" class="def">mapEither</a> ::  (a -&gt; <a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> b c) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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 &lt; &quot;c&quot; then Left a else Right a
 mapEither f (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;), (1,&quot;x&quot;), (7,&quot;z&quot;)])
     == (fromList [(3,&quot;b&quot;), (5,&quot;a&quot;)], fromList [(1,&quot;x&quot;), (7,&quot;z&quot;)])

 mapEither (\ a -&gt; Right a) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;), (1,&quot;x&quot;), (7,&quot;z&quot;)])
     == (empty, fromList [(5,&quot;a&quot;), (3,&quot;b&quot;), (1,&quot;x&quot;), (7,&quot;z&quot;)])
</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> -&gt; a -&gt; <a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> b c) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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 &lt; 5 then Left (k * 2) else Right (a ++ a)
 mapEitherWithKey f (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;), (1,&quot;x&quot;), (7,&quot;z&quot;)])
     == (fromList [(1,2), (3,6)], fromList [(5,&quot;aa&quot;), (7,&quot;zz&quot;)])

 mapEitherWithKey (\_ a -&gt; Right a) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;), (1,&quot;x&quot;), (7,&quot;z&quot;)])
     == (empty, fromList [(1,&quot;x&quot;), (3,&quot;b&quot;), (5,&quot;a&quot;), (7,&quot;z&quot;)])
</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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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,&quot;a&quot;), (3,&quot;b&quot;)]) == (empty, fromList [(3,&quot;b&quot;), (5,&quot;a&quot;)])
 split 3 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (empty, singleton 5 &quot;a&quot;)
 split 4 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (singleton 3 &quot;b&quot;, singleton 5 &quot;a&quot;)
 split 5 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (singleton 3 &quot;b&quot;, empty)
 split 6 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (fromList [(3,&quot;b&quot;), (5,&quot;a&quot;)], 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> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; (<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,&quot;a&quot;), (3,&quot;b&quot;)]) == (empty, Nothing, fromList [(3,&quot;b&quot;), (5,&quot;a&quot;)])
 splitLookup 3 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (empty, Just &quot;b&quot;, singleton 5 &quot;a&quot;)
 splitLookup 4 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (singleton 3 &quot;b&quot;, Nothing, singleton 5 &quot;a&quot;)
 splitLookup 5 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (singleton 3 &quot;b&quot;, Just &quot;a&quot;, empty)
 splitLookup 6 (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == (fromList [(3,&quot;b&quot;), (5,&quot;a&quot;)], 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 =&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 (&lt;=) (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 (&lt;) (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 =&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; b -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> b -&gt; <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 (&lt;=) (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 (&lt;)  (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 -&gt; (<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 -&gt; (<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 -&gt; <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 -&gt; <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 -&gt; (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 -&gt; (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 -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; Just (&quot;X&quot; ++ a)) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;Xb&quot;), (5, &quot;a&quot;)]
 updateMin (\ _ -&gt; Nothing)         (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 5 &quot;a&quot;
</pre></div></div><div class="top"><p class="src"><a name="v:updateMax" class="def">updateMax</a> ::  (a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; Just (&quot;X&quot; ++ a)) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3, &quot;b&quot;), (5, &quot;Xa&quot;)]
 updateMax (\ _ -&gt; Nothing)         (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 3 &quot;b&quot;
</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> -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; Just ((show k) ++ &quot;:&quot; ++ a)) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3,&quot;3:b&quot;), (5,&quot;a&quot;)]
 updateMinWithKey (\ _ _ -&gt; Nothing)                     (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 5 &quot;a&quot;
</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> -&gt; a -&gt; a) -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 -&gt; Just ((show k) ++ &quot;:&quot; ++ a)) (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == fromList [(3,&quot;b&quot;), (5,&quot;5:a&quot;)]
 updateMaxWithKey (\ _ _ -&gt; Nothing)                     (fromList [(5,&quot;a&quot;), (3,&quot;b&quot;)]) == singleton 3 &quot;b&quot;
</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 -&gt; <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 -&gt; <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 -&gt; <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,&quot;a&quot;), (3,&quot;b&quot;)]) == Just ((3,&quot;b&quot;), singleton 5 &quot;a&quot;)
 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 -&gt; <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,&quot;a&quot;), (3,&quot;b&quot;)]) == Just ((5,&quot;a&quot;), singleton 3 &quot;b&quot;)
 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 =&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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 =&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; <a href="Data-IntMap.html#t:IntMap">IntMap</a> a -&gt; <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>