Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 494

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qmap.cpp -->
  <title>QMap Class | Qt Core 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QMap</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QMap Class</h1>
<!-- $$$QMap-brief -->
<p>The <a href="qmap.html">QMap</a> class is a template class that provides a red-black-tree-based dictionary. <a href="#details">More...</a></p>
<!-- @@@QMap -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QMap&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qmultimap.html">QMultiMap</a></p>
</td></tr></table></div><ul>
<li><a href="qmap-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qmap-const-iterator.html">const_iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qmap-iterator.html">iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qmap-key-iterator.html">key_iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#ConstIterator-typedef">ConstIterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#Iterator-typedef">Iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#difference_type-typedef">difference_type</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#key_type-typedef">key_type</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#mapped_type-typedef">mapped_type</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#size_type-typedef">size_type</a></b></td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#QMap">QMap</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#QMap-1">QMap</a></b>(std::initializer_list&lt;std::pair&lt;Key, T&gt; &gt; <i>list</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#QMap-2">QMap</a></b>(const QMap&lt;Key, T&gt; &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#QMap-3">QMap</a></b>(QMap&lt;Key, T&gt; &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#QMap-4">QMap</a></b>(const std::map&lt;Key, T&gt; &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#dtor.QMap">~QMap</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#begin">begin</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#begin-1">begin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#cbegin">cbegin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#cend">cend</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#clear">clear</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#constBegin">constBegin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#constEnd">constEnd</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#constFind">constFind</a></b>(const Key &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#contains">contains</a></b>(const Key &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#count">count</a></b>(const Key &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#count-1">count</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#empty">empty</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#end">end</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#end-1">end</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPair&lt;iterator, iterator&gt; </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#equal_range">equal_range</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPair&lt;const_iterator, const_iterator&gt; </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#equal_range-1">equal_range</a></b>(const Key &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#erase">erase</a></b>(iterator <i>pos</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#find">find</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#find-1">find</a></b>(const Key &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#first">first</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#first-1">first</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const Key &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#firstKey">firstKey</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#insert">insert</a></b>(const Key &amp;<i>key</i>, const T &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#insert-1">insert</a></b>(const_iterator <i>pos</i>, const Key &amp;<i>key</i>, const T &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#insertMulti">insertMulti</a></b>(const Key &amp;<i>key</i>, const T &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#insertMulti-1">insertMulti</a></b>(const_iterator <i>pos</i>, const Key &amp;<i>key</i>, const T &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#isEmpty">isEmpty</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const Key </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#key">key</a></b>(const T &amp;<i>value</i>, const Key &amp;<i>defaultKey</i> = Key()) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> key_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#keyBegin">keyBegin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> key_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#keyEnd">keyEnd</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;Key&gt; </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#keys">keys</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;Key&gt; </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#keys-1">keys</a></b>(const T &amp;<i>value</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#last">last</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#last-1">last</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const Key &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#lastKey">lastKey</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#lowerBound">lowerBound</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#lowerBound-1">lowerBound</a></b>(const Key &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#remove">remove</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#size">size</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#swap">swap</a></b>(QMap&lt;Key, T&gt; &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#take">take</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> std::map&lt;Key, T&gt; </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#toStdMap">toStdMap</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;Key&gt; </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#uniqueKeys">uniqueKeys</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMap&lt;Key, T&gt; &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#unite">unite</a></b>(const QMap&lt;Key, T&gt; &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#upperBound">upperBound</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#upperBound-1">upperBound</a></b>(const Key &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#value">value</a></b>(const Key &amp;<i>key</i>, const T &amp;<i>defaultValue</i> = T()) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;T&gt; </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#values">values</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;T&gt; </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#values-1">values</a></b>(const Key &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#operator-not-eq">operator!=</a></b>(const QMap&lt;Key, T&gt; &amp;<i>other</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMap&lt;Key, T&gt; &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#operator-eq">operator=</a></b>(const QMap&lt;Key, T&gt; &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMap&lt;Key, T&gt; &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#operator-eq-1">operator=</a></b>(QMap&lt;Key, T&gt; &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#operator-eq-eq">operator==</a></b>(const QMap&lt;Key, T&gt; &amp;<i>other</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#operator-5b-5d">operator[]</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T </td><td class="memItemRight bottomAlign"><b><a href="qmap.html#operator-5b-5d-1">operator[]</a></b>(const Key &amp;<i>key</i>) const</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#operator-lt-lt">operator&lt;&lt;</a></b>(QDataStream &amp;<i>out</i>, const QMap&lt;Key, T&gt; &amp;<i>map</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmap.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>in</i>, QMap&lt;Key, T&gt; &amp;<i>map</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QMap-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qmap.html">QMap</a> class is a template class that provides a red-black-tree-based dictionary.</p>
<p><a href="qmap.html">QMap</a>&lt;Key, T&gt; is one of Qt's generic <a href="containers.html">container classes</a>. It stores (key, value) pairs and provides fast lookup of the value associated with a key.</p>
<p><a href="qmap.html">QMap</a> and <a href="qhash.html#qhash">QHash</a> provide very similar functionality. The differences are:</p>
<ul>
<li><a href="qhash.html#qhash">QHash</a> provides average faster lookups than <a href="qmap.html">QMap</a>. (See <a href="containers.html#algorithmic-complexity">Algorithmic Complexity</a> for details.)</li>
<li>When iterating over a <a href="qhash.html#qhash">QHash</a>, the items are arbitrarily ordered. With <a href="qmap.html">QMap</a>, the items are always sorted by key.</li>
<li>The key type of a <a href="qhash.html#qhash">QHash</a> must provide operator==() and a global <a href="qhash.html#qhash">qHash</a>(Key) function. The key type of a <a href="qmap.html">QMap</a> must provide operator&lt;() specifying a total order. Since Qt 5.8&#x2e;1 it is also safe to use a pointer type as key, even if the underlying operator&lt;() does not provide a total order.</li>
</ul>
<p>Here's an example <a href="qmap.html">QMap</a> with <a href="qstring.html">QString</a> keys and <code>int</code> values:</p>
<pre class="cpp">

  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span> map;

</pre>
<p>To insert a (key, value) pair into the map, you can use operator[]():</p>
<pre class="cpp">

  map<span class="operator">[</span><span class="string">&quot;one&quot;</span><span class="operator">]</span> <span class="operator">=</span> <span class="number">1</span>;
  map<span class="operator">[</span><span class="string">&quot;three&quot;</span><span class="operator">]</span> <span class="operator">=</span> <span class="number">3</span>;
  map<span class="operator">[</span><span class="string">&quot;seven&quot;</span><span class="operator">]</span> <span class="operator">=</span> <span class="number">7</span>;

</pre>
<p>This inserts the following three (key, value) pairs into the <a href="qmap.html">QMap</a>: (&quot;one&quot;, 1), (&quot;three&quot;, 3), and (&quot;seven&quot;, 7). Another way to insert items into the map is to use <a href="qmap.html#insert">insert</a>():</p>
<pre class="cpp">

  map<span class="operator">.</span>insert(<span class="string">&quot;twelve&quot;</span><span class="operator">,</span> <span class="number">12</span>);

</pre>
<p>To look up a value, use operator[]() or <a href="qmap.html#value">value</a>():</p>
<pre class="cpp">

  <span class="type">int</span> num1 <span class="operator">=</span> map<span class="operator">[</span><span class="string">&quot;thirteen&quot;</span><span class="operator">]</span>;
  <span class="type">int</span> num2 <span class="operator">=</span> map<span class="operator">.</span>value(<span class="string">&quot;thirteen&quot;</span>);

</pre>
<p>If there is no item with the specified key in the map, these functions return a <a href="containers.html#default-constructed-value">default-constructed value</a>.</p>
<p>If you want to check whether the map contains a certain key, use <a href="qmap.html#contains">contains</a>():</p>
<pre class="cpp">

  <span class="type">int</span> timeout <span class="operator">=</span> <span class="number">30</span>;
  <span class="keyword">if</span> (map<span class="operator">.</span>contains(<span class="string">&quot;TIMEOUT&quot;</span>))
      timeout <span class="operator">=</span> map<span class="operator">.</span>value(<span class="string">&quot;TIMEOUT&quot;</span>);

</pre>
<p>There is also a <a href="qmap.html#value">value</a>() overload that uses its second argument as a default value if there is no item with the specified key:</p>
<pre class="cpp">

  <span class="type">int</span> timeout <span class="operator">=</span> map<span class="operator">.</span>value(<span class="string">&quot;TIMEOUT&quot;</span><span class="operator">,</span> <span class="number">30</span>);

</pre>
<p>In general, we recommend that you use <a href="qmap.html#contains">contains</a>() and <a href="qmap.html#value">value</a>() rather than operator[]() for looking up a key in a map. The reason is that operator[]() silently inserts an item into the map if no item exists with the same key (unless the map is const). For example, the following code snippet will create 1000 items in memory:</p>
<pre class="cpp">

  <span class="comment">// WRONG</span>
  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">,</span> <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> <span class="operator">*</span><span class="operator">&gt;</span> map;
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> <span class="number">1000</span>; <span class="operator">+</span><span class="operator">+</span>i) {
      <span class="keyword">if</span> (map<span class="operator">[</span>i<span class="operator">]</span> <span class="operator">=</span><span class="operator">=</span> okButton)
          cout <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Found button at index &quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> i <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;
  }

</pre>
<p>To avoid this problem, replace <code>map[i]</code> with <code>map.value(i)</code> in the code above.</p>
<p>If you want to navigate through all the (key, value) pairs stored in a <a href="qmap.html">QMap</a>, you can use an iterator. <a href="qmap.html">QMap</a> provides both <a href="containers.html#java-style-iterators">Java-style iterators</a> (<a href="qmapiterator.html">QMapIterator</a> and <a href="qmutablemapiterator.html">QMutableMapIterator</a>) and <a href="containers.html#stl-style-iterators">STL-style iterators</a> (<a href="qmap-const-iterator.html">QMap::const_iterator</a> and <a href="qmap-iterator.html">QMap::iterator</a>). Here's how to iterate over a <a href="qmap.html">QMap</a>&lt;<a href="qstring.html">QString</a>, int&gt; using a Java-style iterator:</p>
<pre class="cpp">

  <span class="type"><a href="qmapiterator.html">QMapIterator</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span> i(map);
  <span class="keyword">while</span> (i<span class="operator">.</span>hasNext()) {
      i<span class="operator">.</span>next();
      cout <span class="operator">&lt;</span><span class="operator">&lt;</span> i<span class="operator">.</span>key() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;: &quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> i<span class="operator">.</span>value() <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;
  }

</pre>
<p>Here's the same code, but using an STL-style iterator this time:</p>
<pre class="cpp">

  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span><span class="operator">::</span>const_iterator i <span class="operator">=</span> map<span class="operator">.</span>constBegin();
  <span class="keyword">while</span> (i <span class="operator">!</span><span class="operator">=</span> map<span class="operator">.</span>constEnd()) {
      cout <span class="operator">&lt;</span><span class="operator">&lt;</span> i<span class="operator">.</span>key() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;: &quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> i<span class="operator">.</span>value() <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;
      <span class="operator">+</span><span class="operator">+</span>i;
  }

</pre>
<p>The items are traversed in ascending key order.</p>
<p>Normally, a <a href="qmap.html">QMap</a> allows only one value per key. If you call <a href="qmap.html#insert">insert</a>() with a key that already exists in the <a href="qmap.html">QMap</a>, the previous value will be erased. For example:</p>
<pre class="cpp">

  map<span class="operator">.</span>insert(<span class="string">&quot;plenty&quot;</span><span class="operator">,</span> <span class="number">100</span>);
  map<span class="operator">.</span>insert(<span class="string">&quot;plenty&quot;</span><span class="operator">,</span> <span class="number">2000</span>);
  <span class="comment">// map.value(&quot;plenty&quot;) == 2000</span>

</pre>
<p>However, you can store multiple values per key by using <a href="qmap.html#insertMulti">insertMulti</a>() instead of <a href="qmap.html#insert">insert</a>() (or using the convenience subclass <a href="qmultimap.html">QMultiMap</a>). If you want to retrieve all the values for a single key, you can use values(const Key &amp;key), which returns a <a href="qlist.html">QList</a>&lt;T&gt;:</p>
<pre class="cpp">

  <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> values <span class="operator">=</span> map<span class="operator">.</span>values(<span class="string">&quot;plenty&quot;</span>);
  <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> values<span class="operator">.</span>size(); <span class="operator">+</span><span class="operator">+</span>i)
      cout <span class="operator">&lt;</span><span class="operator">&lt;</span> values<span class="operator">.</span>at(i) <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;

</pre>
<p>The items that share the same key are available from most recently to least recently inserted. Another approach is to call <a href="qmap.html#find">find</a>() to get the STL-style iterator for the first item with a key and iterate from there:</p>
<pre class="cpp">

  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span><span class="operator">::</span>iterator i <span class="operator">=</span> map<span class="operator">.</span>find(<span class="string">&quot;plenty&quot;</span>);
  <span class="keyword">while</span> (i <span class="operator">!</span><span class="operator">=</span> map<span class="operator">.</span>end() <span class="operator">&amp;</span><span class="operator">&amp;</span> i<span class="operator">.</span>key() <span class="operator">=</span><span class="operator">=</span> <span class="string">&quot;plenty&quot;</span>) {
      cout <span class="operator">&lt;</span><span class="operator">&lt;</span> i<span class="operator">.</span>value() <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;
      <span class="operator">+</span><span class="operator">+</span>i;
  }

</pre>
<p>If you only need to extract the values from a map (not the keys), you can also use <a href="containers.html#foreach">foreach</a>:</p>
<pre class="cpp">

  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span> map;
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  foreach (<span class="type">int</span> value<span class="operator">,</span> map)
      cout <span class="operator">&lt;</span><span class="operator">&lt;</span> value <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;

</pre>
<p>Items can be removed from the map in several ways. One way is to call <a href="qmap.html#remove">remove</a>(); this will remove any item with the given key. Another way is to use <a href="qmutablemapiterator.html#remove">QMutableMapIterator::remove</a>(). In addition, you can clear the entire map using <a href="qmap.html#clear">clear</a>().</p>
<p><a href="qmap.html">QMap</a>'s key and value data types must be <a href="containers.html#assignable-data-types">assignable data types</a>. This covers most data types you are likely to encounter, but the compiler won't let you, for example, store a <a href="../qtwidgets/qwidget.html">QWidget</a> as a value; instead, store a <a href="../qtwidgets/qwidget.html">QWidget</a> *. In addition, <a href="qmap.html">QMap</a>'s key type must provide operator&lt;(). <a href="qmap.html">QMap</a> uses it to keep its items sorted, and assumes that two keys <code>x</code> and <code>y</code> are equal if neither <code>x &lt; y</code> nor <code>y &lt; x</code> is true.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="preprocessor">#ifndef EMPLOYEE_H</span>
  <span class="preprocessor">#define EMPLOYEE_H</span>

  <span class="keyword">class</span> Employee
  {
  <span class="keyword">public</span>:
      Employee() {}
      Employee(<span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span> <span class="operator">&amp;</span>name<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qdate.html">QDate</a></span> <span class="operator">&amp;</span>dateOfBirth);
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

  <span class="keyword">private</span>:
      <span class="type"><a href="qstring.html">QString</a></span> myName;
      <span class="type"><a href="qdate.html">QDate</a></span> myDateOfBirth;
  };

  <span class="keyword">inline</span> bool <span class="keyword">operator</span><span class="operator">&lt;</span>(<span class="keyword">const</span> Employee <span class="operator">&amp;</span>e1<span class="operator">,</span> <span class="keyword">const</span> Employee <span class="operator">&amp;</span>e2)
  {
      <span class="keyword">if</span> (e1<span class="operator">.</span>name() <span class="operator">!</span><span class="operator">=</span> e2<span class="operator">.</span>name())
          <span class="keyword">return</span> e1<span class="operator">.</span>name() <span class="operator">&lt;</span> e2<span class="operator">.</span>name();
      <span class="keyword">return</span> e1<span class="operator">.</span>dateOfBirth() <span class="operator">&lt;</span> e2<span class="operator">.</span>dateOfBirth();
  }

  <span class="preprocessor">#endif // EMPLOYEE_H</span>

</pre>
<p>In the example, we start by comparing the employees' names. If they're equal, we compare their dates of birth to break the tie.</p>
</div>
<p><b>See also </b><a href="qmapiterator.html">QMapIterator</a>, <a href="qmutablemapiterator.html">QMutableMapIterator</a>, <a href="qhash.html#qhash">QHash</a>, and <a href="qset.html">QSet</a>.</p>
<!-- @@@QMap -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ConstIterator -->
<h3 class="fn" id="ConstIterator-typedef"><a name="ConstIterator-typedef"></a>typedef QMap::<span class="name">ConstIterator</span></h3>
<p>Qt-style synonym for <a href="qmap-const-iterator.html">QMap::const_iterator</a>.</p>
<!-- @@@ConstIterator -->
<!-- $$$Iterator -->
<h3 class="fn" id="Iterator-typedef"><a name="Iterator-typedef"></a>typedef QMap::<span class="name">Iterator</span></h3>
<p>Qt-style synonym for <a href="qmap-iterator.html">QMap::iterator</a>.</p>
<!-- @@@Iterator -->
<!-- $$$difference_type -->
<h3 class="fn" id="difference_type-typedef"><a name="difference_type-typedef"></a>typedef QMap::<span class="name">difference_type</span></h3>
<p>Typedef for ptrdiff_t. Provided for STL compatibility.</p>
<!-- @@@difference_type -->
<!-- $$$key_type -->
<h3 class="fn" id="key_type-typedef"><a name="key_type-typedef"></a>typedef QMap::<span class="name">key_type</span></h3>
<p>Typedef for Key. Provided for STL compatibility.</p>
<!-- @@@key_type -->
<!-- $$$mapped_type -->
<h3 class="fn" id="mapped_type-typedef"><a name="mapped_type-typedef"></a>typedef QMap::<span class="name">mapped_type</span></h3>
<p>Typedef for T. Provided for STL compatibility.</p>
<!-- @@@mapped_type -->
<!-- $$$size_type -->
<h3 class="fn" id="size_type-typedef"><a name="size_type-typedef"></a>typedef QMap::<span class="name">size_type</span></h3>
<p>Typedef for int. Provided for STL compatibility.</p>
<!-- @@@size_type -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QMap[overload1]$$$QMap -->
<h3 class="fn" id="QMap"><a name="QMap"></a>QMap::<span class="name">QMap</span>()</h3>
<p>Constructs an empty map.</p>
<p><b>See also </b><a href="qmap.html#clear">clear</a>().</p>
<!-- @@@QMap -->
<!-- $$$QMap$$$QMapstd::initializer_list<std::pair<Key,T>> -->
<h3 class="fn" id="QMap-1"><a name="QMap-1"></a>QMap::<span class="name">QMap</span>(<span class="type">std::initializer_list</span>&lt;<span class="type">std::pair</span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &gt; <i>list</i>)</h3>
<p>Constructs a map with a copy of each of the elements in the initializer list <i>list</i>.</p>
<p>This function is only available if the program is being compiled in C++11 mode.</p>
<p>This function was introduced in  Qt 5.1.</p>
<!-- @@@QMap -->
<!-- $$$QMap$$$QMapconstQMap<Key,T>& -->
<h3 class="fn" id="QMap-2"><a name="QMap-2"></a>QMap::<span class="name">QMap</span>(const <span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>other</i>)</h3>
<p>Constructs a copy of <i>other</i>.</p>
<p>This operation occurs in <a href="containers.html#constant-time">constant time</a>, because <a href="qmap.html">QMap</a> is <a href="implicit-sharing.html">implicitly shared</a>. This makes returning a <a href="qmap.html">QMap</a> from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and this takes <a href="containers.html#linear-time">linear time</a>.</p>
<p><b>See also </b><a href="qmap.html#operator-eq">operator=</a>().</p>
<!-- @@@QMap -->
<!-- $$$QMap$$$QMapQMap<Key,T>&& -->
<h3 class="fn" id="QMap-3"><a name="QMap-3"></a>QMap::<span class="name">QMap</span>(<span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;&amp;<i>other</i>)</h3>
<p>Move-constructs a <a href="qmap.html">QMap</a> instance, making it point at the same object that <i>other</i> was pointing to.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@QMap -->
<!-- $$$QMap$$$QMapconststd::map<Key,T>& -->
<h3 class="fn" id="QMap-4"><a name="QMap-4"></a>QMap::<span class="name">QMap</span>(const <span class="type">std::map</span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>other</i>)</h3>
<p>Constructs a copy of <i>other</i>.</p>
<p><b>See also </b><a href="qmap.html#toStdMap">toStdMap</a>().</p>
<!-- @@@QMap -->
<!-- $$$~QMap[overload1]$$$~QMap -->
<h3 class="fn" id="dtor.QMap"><a name="dtor.QMap"></a>QMap::<span class="name">~QMap</span>()</h3>
<p>Destroys the map. References to the values in the map, and all iterators over this map, become invalid.</p>
<!-- @@@~QMap -->
<!-- $$$begin[overload1]$$$begin -->
<h3 class="fn" id="begin"><a name="begin"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">begin</span>()</h3>
<p>Returns an <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the map.</p>
<p><b>See also </b><a href="qmap.html#constBegin">constBegin</a>() and <a href="qmap.html#end">end</a>().</p>
<!-- @@@begin -->
<!-- $$$begin$$$begin -->
<h3 class="fn" id="begin-1"><a name="begin-1"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">begin</span>() const</h3>
<p>This is an overloaded function.</p>
<!-- @@@begin -->
<!-- $$$cbegin[overload1]$$$cbegin -->
<h3 class="fn" id="cbegin"><a name="cbegin"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">cbegin</span>() const</h3>
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the map.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qmap.html#begin">begin</a>() and <a href="qmap.html#cend">cend</a>().</p>
<!-- @@@cbegin -->
<!-- $$$cend[overload1]$$$cend -->
<h3 class="fn" id="cend"><a name="cend"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">cend</span>() const</h3>
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the map.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qmap.html#cbegin">cbegin</a>() and <a href="qmap.html#end">end</a>().</p>
<!-- @@@cend -->
<!-- $$$clear[overload1]$$$clear -->
<h3 class="fn" id="clear"><a name="clear"></a><span class="type">void</span> QMap::<span class="name">clear</span>()</h3>
<p>Removes all items from the map.</p>
<p><b>See also </b><a href="qmap.html#remove">remove</a>().</p>
<!-- @@@clear -->
<!-- $$$constBegin[overload1]$$$constBegin -->
<h3 class="fn" id="constBegin"><a name="constBegin"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">constBegin</span>() const</h3>
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the map.</p>
<p><b>See also </b><a href="qmap.html#begin">begin</a>() and <a href="qmap.html#constEnd">constEnd</a>().</p>
<!-- @@@constBegin -->
<!-- $$$constEnd[overload1]$$$constEnd -->
<h3 class="fn" id="constEnd"><a name="constEnd"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">constEnd</span>() const</h3>
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the map.</p>
<p><b>See also </b><a href="qmap.html#constBegin">constBegin</a>() and <a href="qmap.html#end">end</a>().</p>
<!-- @@@constEnd -->
<!-- $$$constFind[overload1]$$$constFindconstKey& -->
<h3 class="fn" id="constFind"><a name="constFind"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">constFind</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>Returns an const iterator pointing to the item with key <i>key</i> in the map.</p>
<p>If the map contains no item with key <i>key</i>, the function returns <a href="qmap.html#constEnd">constEnd</a>().</p>
<p>This function was introduced in  Qt 4.1.</p>
<p><b>See also </b><a href="qmap.html#find">find</a>() and <a href="qmultimap.html#constFind">QMultiMap::constFind</a>().</p>
<!-- @@@constFind -->
<!-- $$$contains[overload1]$$$containsconstKey& -->
<h3 class="fn" id="contains"><a name="contains"></a><span class="type">bool</span> QMap::<span class="name">contains</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>Returns <code>true</code> if the map contains an item with key <i>key</i>; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qmap.html#count-1">count</a>() and <a href="qmultimap.html#contains">QMultiMap::contains</a>().</p>
<!-- @@@contains -->
<!-- $$$count[overload1]$$$countconstKey& -->
<h3 class="fn" id="count"><a name="count"></a><span class="type">int</span> QMap::<span class="name">count</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>Returns the number of items associated with key <i>key</i>.</p>
<p><b>See also </b><a href="qmap.html#contains">contains</a>(), <a href="qmap.html#insertMulti">insertMulti</a>(), and <a href="qmultimap.html#count">QMultiMap::count</a>().</p>
<!-- @@@count -->
<!-- $$$count$$$count -->
<h3 class="fn" id="count-1"><a name="count-1"></a><span class="type">int</span> QMap::<span class="name">count</span>() const</h3>
<p>This is an overloaded function.</p>
<p>Same as <a href="qmap.html#size">size</a>().</p>
<!-- @@@count -->
<!-- $$$empty[overload1]$$$empty -->
<h3 class="fn" id="empty"><a name="empty"></a><span class="type">bool</span> QMap::<span class="name">empty</span>() const</h3>
<p>This function is provided for STL compatibility. It is equivalent to <a href="qmap.html#isEmpty">isEmpty</a>(), returning true if the map is empty; otherwise returning false.</p>
<!-- @@@empty -->
<!-- $$$end[overload1]$$$end -->
<h3 class="fn" id="end"><a name="end"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">end</span>()</h3>
<p>Returns an <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the map.</p>
<p><b>See also </b><a href="qmap.html#begin">begin</a>() and <a href="qmap.html#constEnd">constEnd</a>().</p>
<!-- @@@end -->
<!-- $$$end$$$end -->
<h3 class="fn" id="end-1"><a name="end-1"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">end</span>() const</h3>
<p>This is an overloaded function.</p>
<!-- @@@end -->
<!-- $$$equal_range[overload1]$$$equal_rangeconstKey& -->
<h3 class="fn" id="equal_range"><a name="equal_range"></a><span class="type"><a href="qpair.html">QPair</a></span>&lt;<span class="type"><a href="qmap-iterator.html">iterator</a></span>, <span class="type"><a href="qmap-iterator.html">iterator</a></span>&gt; QMap::<span class="name">equal_range</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Returns a pair of iterators delimiting the range of values <code>[first, second)</code>, that are stored under <i>key</i>.</p>
<!-- @@@equal_range -->
<!-- $$$equal_range$$$equal_rangeconstKey& -->
<h3 class="fn" id="equal_range-1"><a name="equal_range-1"></a><span class="type"><a href="qpair.html">QPair</a></span>&lt;<span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span>, <span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span>&gt; QMap::<span class="name">equal_range</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>This is an overloaded function.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@equal_range -->
<!-- $$$erase[overload1]$$$eraseiterator -->
<h3 class="fn" id="erase"><a name="erase"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">erase</span>(<span class="type"><a href="qmap-iterator.html">iterator</a></span> <i>pos</i>)</h3>
<p>Removes the (key, value) pair pointed to by the iterator <i>pos</i> from the map, and returns an iterator to the next item in the map.</p>
<p><b>See also </b><a href="qmap.html#remove">remove</a>().</p>
<!-- @@@erase -->
<!-- $$$find[overload1]$$$findconstKey& -->
<h3 class="fn" id="find"><a name="find"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">find</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Returns an iterator pointing to the item with key <i>key</i> in the map.</p>
<p>If the map contains no item with key <i>key</i>, the function returns <a href="qmap.html#end">end</a>().</p>
<p>If the map contains multiple items with key <i>key</i>, this function returns an iterator that points to the most recently inserted value. The other values are accessible by incrementing the iterator. For example, here's some code that iterates over all the items with the same key:</p>
<pre class="cpp">

  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span> map;
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span><span class="operator">::</span>const_iterator i <span class="operator">=</span> map<span class="operator">.</span>find(<span class="string">&quot;HDR&quot;</span>);
  <span class="keyword">while</span> (i <span class="operator">!</span><span class="operator">=</span> map<span class="operator">.</span>end() <span class="operator">&amp;</span><span class="operator">&amp;</span> i<span class="operator">.</span>key() <span class="operator">=</span><span class="operator">=</span> <span class="string">&quot;HDR&quot;</span>) {
      cout <span class="operator">&lt;</span><span class="operator">&lt;</span> i<span class="operator">.</span>value() <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;
      <span class="operator">+</span><span class="operator">+</span>i;
  }

</pre>
<p><b>See also </b><a href="qmap.html#constFind">constFind</a>(), <a href="qmap.html#value">value</a>(), <a href="qmap.html#values">values</a>(), <a href="qmap.html#lowerBound">lowerBound</a>(), <a href="qmap.html#upperBound">upperBound</a>(), and <a href="qmultimap.html#find">QMultiMap::find</a>().</p>
<!-- @@@find -->
<!-- $$$find$$$findconstKey& -->
<h3 class="fn" id="find-1"><a name="find-1"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">find</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>This is an overloaded function.</p>
<!-- @@@find -->
<!-- $$$first[overload1]$$$first -->
<h3 class="fn" id="first"><a name="first"></a><span class="type">T</span> &amp;QMap::<span class="name">first</span>()</h3>
<p>Returns a reference to the first value in the map, that is the value mapped to the smallest key. This function assumes that the map is not empty.</p>
<p>When unshared (or const version is called), this executes in <a href="containers.html#constant-time">constant time</a>.</p>
<p>This function was introduced in  Qt 5.2.</p>
<p><b>See also </b><a href="qmap.html#last">last</a>(), <a href="qmap.html#firstKey">firstKey</a>(), and <a href="qmap.html#isEmpty">isEmpty</a>().</p>
<!-- @@@first -->
<!-- $$$first$$$first -->
<h3 class="fn" id="first-1"><a name="first-1"></a>const <span class="type">T</span> &amp;QMap::<span class="name">first</span>() const</h3>
<p>This is an overloaded function.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@first -->
<!-- $$$firstKey[overload1]$$$firstKey -->
<h3 class="fn" id="firstKey"><a name="firstKey"></a>const <span class="type">Key</span> &amp;QMap::<span class="name">firstKey</span>() const</h3>
<p>Returns a reference to the smallest key in the map. This function assumes that the map is not empty.</p>
<p>This executes in <a href="containers.html#constant-time">constant time</a>.</p>
<p>This function was introduced in  Qt 5.2.</p>
<p><b>See also </b><a href="qmap.html#lastKey">lastKey</a>(), <a href="qmap.html#first">first</a>(), <a href="qmap.html#keyBegin">keyBegin</a>(), and <a href="qmap.html#isEmpty">isEmpty</a>().</p>
<!-- @@@firstKey -->
<!-- $$$insert[overload1]$$$insertconstKey&constT& -->
<h3 class="fn" id="insert"><a name="insert"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">insert</span>(const <span class="type">Key</span> &amp;<i>key</i>, const <span class="type">T</span> &amp;<i>value</i>)</h3>
<p>Inserts a new item with the key <i>key</i> and a value of <i>value</i>.</p>
<p>If there is already an item with the key <i>key</i>, that item's value is replaced with <i>value</i>.</p>
<p>If there are multiple items with the key <i>key</i>, the most recently inserted item's value is replaced with <i>value</i>.</p>
<p><b>See also </b><a href="qmap.html#insertMulti">insertMulti</a>().</p>
<!-- @@@insert -->
<!-- $$$insert$$$insertconst_iteratorconstKey&constT& -->
<h3 class="fn" id="insert-1"><a name="insert-1"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">insert</span>(<span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> <i>pos</i>, const <span class="type">Key</span> &amp;<i>key</i>, const <span class="type">T</span> &amp;<i>value</i>)</h3>
<p>This is an overloaded function.</p>
<p>Inserts a new item with the key <i>key</i> and value <i>value</i> and with hint <i>pos</i> suggesting where to do the insert.</p>
<p>If <a href="qmap.html#constBegin">constBegin</a>() is used as hint it indicates that the <i>key</i> is less than any key in the map while <a href="qmap.html#constEnd">constEnd</a>() suggests that the <i>key</i> is (strictly) larger than any key in the map. Otherwise the hint should meet the condition (<i>pos</i> - 1).<a href="qmap.html#key">key</a>() &lt; <i>key</i> &lt;= pos.<a href="qmap.html#key">key</a>(). If the hint <i>pos</i> is wrong it is ignored and a regular insert is done.</p>
<p>If there is already an item with the key <i>key</i>, that item's value is replaced with <i>value</i>.</p>
<p>If there are multiple items with the key <i>key</i>, then exactly one of them is replaced with <i>value</i>.</p>
<p>If the hint is correct and the map is unshared, the insert executes in amortized <a href="containers.html#constant-time">constant time</a>.</p>
<p>When creating a map from sorted data inserting the largest key first with <a href="qmap.html#constBegin">constBegin</a>() is faster than inserting in sorted order with <a href="qmap.html#constEnd">constEnd</a>(), since <a href="qmap.html#constEnd">constEnd</a>() - 1 (which is needed to check if the hint is valid) needs <a href="containers.html#logarithmic-time">logarithmic time</a>.</p>
<p><b>Note:</b> Be careful with the hint. Providing an iterator from an older shared instance might crash but there is also a risk that it will silently corrupt both the map and the <i>pos</i> map.</p>
<p>This function was introduced in  Qt 5.1.</p>
<p><b>See also </b><a href="qmap.html#insertMulti">insertMulti</a>().</p>
<!-- @@@insert -->
<!-- $$$insertMulti[overload1]$$$insertMulticonstKey&constT& -->
<h3 class="fn" id="insertMulti"><a name="insertMulti"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">insertMulti</span>(const <span class="type">Key</span> &amp;<i>key</i>, const <span class="type">T</span> &amp;<i>value</i>)</h3>
<p>Inserts a new item with the key <i>key</i> and a value of <i>value</i>.</p>
<p>If there is already an item with the same key in the map, this function will simply create a new one. (This behavior is different from <a href="qmap.html#insert">insert</a>(), which overwrites the value of an existing item.)</p>
<p><b>See also </b><a href="qmap.html#insert">insert</a>() and <a href="qmap.html#values">values</a>().</p>
<!-- @@@insertMulti -->
<!-- $$$insertMulti$$$insertMulticonst_iteratorconstKey&constT& -->
<h3 class="fn" id="insertMulti-1"><a name="insertMulti-1"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">insertMulti</span>(<span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> <i>pos</i>, const <span class="type">Key</span> &amp;<i>key</i>, const <span class="type">T</span> &amp;<i>value</i>)</h3>
<p>This is an overloaded function.</p>
<p>Inserts a new item with the key <i>key</i> and value <i>value</i> and with hint <i>pos</i> suggesting where to do the insert.</p>
<p>If <a href="qmap.html#constBegin">constBegin</a>() is used as hint it indicates that the <i>key</i> is less than any key in the map while <a href="qmap.html#constEnd">constEnd</a>() suggests that the <i>key</i> is larger than any key in the map. Otherwise the hint should meet the condition (<i>pos</i> - 1).<a href="qmap.html#key">key</a>() &lt; <i>key</i> &lt;= pos.<a href="qmap.html#key">key</a>(). If the hint <i>pos</i> is wrong it is ignored and a regular <a href="qmap.html#insertMulti">insertMulti</a> is done.</p>
<p>If there is already an item with the same key in the map, this function will simply create a new one.</p>
<p><b>Note:</b> Be careful with the hint. Providing an iterator from an older shared instance might crash but there is also a risk that it will silently corrupt both the map and the <i>pos</i> map.</p>
<p>This function was introduced in  Qt 5.1.</p>
<p><b>See also </b><a href="qmap.html#insert">insert</a>().</p>
<!-- @@@insertMulti -->
<!-- $$$isEmpty[overload1]$$$isEmpty -->
<h3 class="fn" id="isEmpty"><a name="isEmpty"></a><span class="type">bool</span> QMap::<span class="name">isEmpty</span>() const</h3>
<p>Returns <code>true</code> if the map contains no items; otherwise returns false.</p>
<p><b>See also </b><a href="qmap.html#size">size</a>().</p>
<!-- @@@isEmpty -->
<!-- $$$key[overload1]$$$keyconstT&constKey& -->
<h3 class="fn" id="key"><a name="key"></a>const <span class="type">Key</span> QMap::<span class="name">key</span>(const <span class="type">T</span> &amp;<i>value</i>, const <span class="type">Key</span> &amp;<i>defaultKey</i> = Key()) const</h3>
<p>This is an overloaded function.</p>
<p>Returns the first key with value <i>value</i>, or <i>defaultKey</i> if the map contains no item with value <i>value</i>. If no <i>defaultKey</i> is provided the function returns a <a href="containers.html#default-constructed-value">default-constructed key</a>.</p>
<p>This function can be slow (<a href="containers.html#linear-time">linear time</a>), because <a href="qmap.html">QMap</a>'s internal data structure is optimized for fast lookup by key, not by value.</p>
<p>This function was introduced in  Qt 4.3.</p>
<p><b>See also </b><a href="qmap.html#value">value</a>() and <a href="qmap.html#keys">keys</a>().</p>
<!-- @@@key -->
<!-- $$$keyBegin[overload1]$$$keyBegin -->
<h3 class="fn" id="keyBegin"><a name="keyBegin"></a><span class="type"><a href="qmap-key-iterator.html">key_iterator</a></span> QMap::<span class="name">keyBegin</span>() const</h3>
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first key in the map.</p>
<p>This function was introduced in  Qt 5.6.</p>
<p><b>See also </b><a href="qmap.html#keyEnd">keyEnd</a>() and <a href="qmap.html#firstKey">firstKey</a>().</p>
<!-- @@@keyBegin -->
<!-- $$$keyEnd[overload1]$$$keyEnd -->
<h3 class="fn" id="keyEnd"><a name="keyEnd"></a><span class="type"><a href="qmap-key-iterator.html">key_iterator</a></span> QMap::<span class="name">keyEnd</span>() const</h3>
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last key in the map.</p>
<p>This function was introduced in  Qt 5.6.</p>
<p><b>See also </b><a href="qmap.html#keyBegin">keyBegin</a>() and <a href="qmap.html#lastKey">lastKey</a>().</p>
<!-- @@@keyEnd -->
<!-- $$$keys[overload1]$$$keys -->
<h3 class="fn" id="keys"><a name="keys"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">Key</span>&gt; QMap::<span class="name">keys</span>() const</h3>
<p>Returns a list containing all the keys in the map in ascending order. Keys that occur multiple times in the map (because items were inserted with <a href="qmap.html#insertMulti">insertMulti</a>(), or <a href="qmap.html#unite">unite</a>() was used) also occur multiple times in the list.</p>
<p>To obtain a list of unique keys, where each key from the map only occurs once, use <a href="qmap.html#uniqueKeys">uniqueKeys</a>().</p>
<p>The order is guaranteed to be the same as that used by <a href="qmap.html#values">values</a>().</p>
<p><b>See also </b><a href="qmap.html#uniqueKeys">uniqueKeys</a>(), <a href="qmap.html#values">values</a>(), and <a href="qmap.html#key">key</a>().</p>
<!-- @@@keys -->
<!-- $$$keys$$$keysconstT& -->
<h3 class="fn" id="keys-1"><a name="keys-1"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">Key</span>&gt; QMap::<span class="name">keys</span>(const <span class="type">T</span> &amp;<i>value</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Returns a list containing all the keys associated with value <i>value</i> in ascending order.</p>
<p>This function can be slow (<a href="containers.html#linear-time">linear time</a>), because <a href="qmap.html">QMap</a>'s internal data structure is optimized for fast lookup by key, not by value.</p>
<!-- @@@keys -->
<!-- $$$last[overload1]$$$last -->
<h3 class="fn" id="last"><a name="last"></a><span class="type">T</span> &amp;QMap::<span class="name">last</span>()</h3>
<p>Returns a reference to the last value in the map, that is the value mapped to the largest key. This function assumes that the map is not empty.</p>
<p>When unshared (or const version is called), this executes in <a href="containers.html#logarithmic-time">logarithmic time</a>.</p>
<p>This function was introduced in  Qt 5.2.</p>
<p><b>See also </b><a href="qmap.html#first">first</a>(), <a href="qmap.html#lastKey">lastKey</a>(), and <a href="qmap.html#isEmpty">isEmpty</a>().</p>
<!-- @@@last -->
<!-- $$$last$$$last -->
<h3 class="fn" id="last-1"><a name="last-1"></a>const <span class="type">T</span> &amp;QMap::<span class="name">last</span>() const</h3>
<p>This is an overloaded function.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@last -->
<!-- $$$lastKey[overload1]$$$lastKey -->
<h3 class="fn" id="lastKey"><a name="lastKey"></a>const <span class="type">Key</span> &amp;QMap::<span class="name">lastKey</span>() const</h3>
<p>Returns a reference to the largest key in the map. This function assumes that the map is not empty.</p>
<p>This executes in <a href="containers.html#logarithmic-time">logarithmic time</a>.</p>
<p>This function was introduced in  Qt 5.2.</p>
<p><b>See also </b><a href="qmap.html#firstKey">firstKey</a>(), <a href="qmap.html#last">last</a>(), <a href="qmap.html#keyEnd">keyEnd</a>(), and <a href="qmap.html#isEmpty">isEmpty</a>().</p>
<!-- @@@lastKey -->
<!-- $$$lowerBound[overload1]$$$lowerBoundconstKey& -->
<h3 class="fn" id="lowerBound"><a name="lowerBound"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">lowerBound</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Returns an iterator pointing to the first item with key <i>key</i> in the map. If the map contains no item with key <i>key</i>, the function returns an iterator to the nearest item with a greater key.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">,</span> <span class="type"><a href="qstring.html">QString</a></span><span class="operator">&gt;</span> map;
  map<span class="operator">.</span>insert(<span class="number">1</span><span class="operator">,</span> <span class="string">&quot;one&quot;</span>);
  map<span class="operator">.</span>insert(<span class="number">5</span><span class="operator">,</span> <span class="string">&quot;five&quot;</span>);
  map<span class="operator">.</span>insert(<span class="number">10</span><span class="operator">,</span> <span class="string">&quot;ten&quot;</span>);

  map<span class="operator">.</span>lowerBound(<span class="number">0</span>);      <span class="comment">// returns iterator to (1, &quot;one&quot;)</span>
  map<span class="operator">.</span>lowerBound(<span class="number">1</span>);      <span class="comment">// returns iterator to (1, &quot;one&quot;)</span>
  map<span class="operator">.</span>lowerBound(<span class="number">2</span>);      <span class="comment">// returns iterator to (5, &quot;five&quot;)</span>
  map<span class="operator">.</span>lowerBound(<span class="number">10</span>);     <span class="comment">// returns iterator to (10, &quot;ten&quot;)</span>
  map<span class="operator">.</span>lowerBound(<span class="number">999</span>);    <span class="comment">// returns end()</span>

</pre>
<p>If the map contains multiple items with key <i>key</i>, this function returns an iterator that points to the most recently inserted value. The other values are accessible by incrementing the iterator. For example, here's some code that iterates over all the items with the same key:</p>
<pre class="cpp">

  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span> map;
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span><span class="operator">::</span>const_iterator i <span class="operator">=</span> map<span class="operator">.</span>lowerBound(<span class="string">&quot;HDR&quot;</span>);
  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span><span class="operator">::</span>const_iterator upperBound <span class="operator">=</span> map<span class="operator">.</span>upperBound(<span class="string">&quot;HDR&quot;</span>);
  <span class="keyword">while</span> (i <span class="operator">!</span><span class="operator">=</span> upperBound) {
      cout <span class="operator">&lt;</span><span class="operator">&lt;</span> i<span class="operator">.</span>value() <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;
      <span class="operator">+</span><span class="operator">+</span>i;
  }

</pre>
<p><b>See also </b><a href="qmap.html#upperBound">upperBound</a>() and <a href="qmap.html#find">find</a>().</p>
<!-- @@@lowerBound -->
<!-- $$$lowerBound$$$lowerBoundconstKey& -->
<h3 class="fn" id="lowerBound-1"><a name="lowerBound-1"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">lowerBound</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>This is an overloaded function.</p>
<!-- @@@lowerBound -->
<!-- $$$remove[overload1]$$$removeconstKey& -->
<h3 class="fn" id="remove"><a name="remove"></a><span class="type">int</span> QMap::<span class="name">remove</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Removes all the items that have the key <i>key</i> from the map. Returns the number of items removed which is usually 1 but will be 0 if the key isn't in the map, or &gt; 1 if <a href="qmap.html#insertMulti">insertMulti</a>() has been used with the <i>key</i>.</p>
<p><b>See also </b><a href="qmap.html#clear">clear</a>(), <a href="qmap.html#take">take</a>(), and <a href="qmultimap.html#remove">QMultiMap::remove</a>().</p>
<!-- @@@remove -->
<!-- $$$size[overload1]$$$size -->
<h3 class="fn" id="size"><a name="size"></a><span class="type">int</span> QMap::<span class="name">size</span>() const</h3>
<p>Returns the number of (key, value) pairs in the map.</p>
<p><b>See also </b><a href="qmap.html#isEmpty">isEmpty</a>() and <a href="qmap.html#count-1">count</a>().</p>
<!-- @@@size -->
<!-- $$$swap[overload1]$$$swapQMap<Key,T>& -->
<h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QMap::<span class="name">swap</span>(<span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>other</i>)</h3>
<p>Swaps map <i>other</i> with this map. This operation is very fast and never fails.</p>
<p>This function was introduced in  Qt 4.8.</p>
<!-- @@@swap -->
<!-- $$$take[overload1]$$$takeconstKey& -->
<h3 class="fn" id="take"><a name="take"></a><span class="type">T</span> QMap::<span class="name">take</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Removes the item with the key <i>key</i> from the map and returns the value associated with it.</p>
<p>If the item does not exist in the map, the function simply returns a <a href="containers.html#default-constructed-value">default-constructed value</a>. If there are multiple items for <i>key</i> in the map, only the most recently inserted one is removed and returned.</p>
<p>If you don't use the return value, <a href="qmap.html#remove">remove</a>() is more efficient.</p>
<p><b>See also </b><a href="qmap.html#remove">remove</a>().</p>
<!-- @@@take -->
<!-- $$$toStdMap[overload1]$$$toStdMap -->
<h3 class="fn" id="toStdMap"><a name="toStdMap"></a><span class="type">std::map</span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; QMap::<span class="name">toStdMap</span>() const</h3>
<p>Returns an STL map equivalent to this <a href="qmap.html">QMap</a>.</p>
<!-- @@@toStdMap -->
<!-- $$$uniqueKeys[overload1]$$$uniqueKeys -->
<h3 class="fn" id="uniqueKeys"><a name="uniqueKeys"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">Key</span>&gt; QMap::<span class="name">uniqueKeys</span>() const</h3>
<p>Returns a list containing all the keys in the map in ascending order. Keys that occur multiple times in the map (because items were inserted with <a href="qmap.html#insertMulti">insertMulti</a>(), or <a href="qmap.html#unite">unite</a>() was used) occur only once in the returned list.</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qmap.html#keys">keys</a>() and <a href="qmap.html#values">values</a>().</p>
<!-- @@@uniqueKeys -->
<!-- $$$unite[overload1]$$$uniteconstQMap<Key,T>& -->
<h3 class="fn" id="unite"><a name="unite"></a><span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;QMap::<span class="name">unite</span>(const <span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>other</i>)</h3>
<p>Inserts all the items in the <i>other</i> map into this map. If a key is common to both maps, the resulting map will contain the key multiple times.</p>
<p><b>See also </b><a href="qmap.html#insertMulti">insertMulti</a>().</p>
<!-- @@@unite -->
<!-- $$$upperBound[overload1]$$$upperBoundconstKey& -->
<h3 class="fn" id="upperBound"><a name="upperBound"></a><span class="type"><a href="qmap-iterator.html">iterator</a></span> QMap::<span class="name">upperBound</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Returns an iterator pointing to the item that immediately follows the last item with key <i>key</i> in the map. If the map contains no item with key <i>key</i>, the function returns an iterator to the nearest item with a greater key.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qmap.html#QMap">QMap</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">,</span> <span class="type"><a href="qstring.html">QString</a></span><span class="operator">&gt;</span> map;
  map<span class="operator">.</span>insert(<span class="number">1</span><span class="operator">,</span> <span class="string">&quot;one&quot;</span>);
  map<span class="operator">.</span>insert(<span class="number">5</span><span class="operator">,</span> <span class="string">&quot;five&quot;</span>);
  map<span class="operator">.</span>insert(<span class="number">10</span><span class="operator">,</span> <span class="string">&quot;ten&quot;</span>);

  map<span class="operator">.</span>upperBound(<span class="number">0</span>);      <span class="comment">// returns iterator to (1, &quot;one&quot;)</span>
  map<span class="operator">.</span>upperBound(<span class="number">1</span>);      <span class="comment">// returns iterator to (5, &quot;five&quot;)</span>
  map<span class="operator">.</span>upperBound(<span class="number">2</span>);      <span class="comment">// returns iterator to (5, &quot;five&quot;)</span>
  map<span class="operator">.</span>upperBound(<span class="number">10</span>);     <span class="comment">// returns end()</span>
  map<span class="operator">.</span>upperBound(<span class="number">999</span>);    <span class="comment">// returns end()</span>

</pre>
<p><b>See also </b><a href="qmap.html#lowerBound">lowerBound</a>() and <a href="qmap.html#find">find</a>().</p>
<!-- @@@upperBound -->
<!-- $$$upperBound$$$upperBoundconstKey& -->
<h3 class="fn" id="upperBound-1"><a name="upperBound-1"></a><span class="type"><a href="qmap-const-iterator.html">const_iterator</a></span> QMap::<span class="name">upperBound</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>This is an overloaded function.</p>
<!-- @@@upperBound -->
<!-- $$$value[overload1]$$$valueconstKey&constT& -->
<h3 class="fn" id="value"><a name="value"></a>const <span class="type">T</span> QMap::<span class="name">value</span>(const <span class="type">Key</span> &amp;<i>key</i>, const <span class="type">T</span> &amp;<i>defaultValue</i> = T()) const</h3>
<p>Returns the value associated with the key <i>key</i>.</p>
<p>If the map contains no item with key <i>key</i>, the function returns <i>defaultValue</i>. If no <i>defaultValue</i> is specified, the function returns a <a href="containers.html#default-constructed-value">default-constructed value</a>. If there are multiple items for <i>key</i> in the map, the value of the most recently inserted one is returned.</p>
<p><b>See also </b><a href="qmap.html#key">key</a>(), <a href="qmap.html#values">values</a>(), <a href="qmap.html#contains">contains</a>(), and <a href="qmap.html#operator-5b-5d">operator[]</a>().</p>
<!-- @@@value -->
<!-- $$$values[overload1]$$$values -->
<h3 class="fn" id="values"><a name="values"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">T</span>&gt; QMap::<span class="name">values</span>() const</h3>
<p>Returns a list containing all the values in the map, in ascending order of their keys. If a key is associated with multiple values, all of its values will be in the list, and not just the most recently inserted one.</p>
<p><b>See also </b><a href="qmap.html#keys">keys</a>() and <a href="qmap.html#value">value</a>().</p>
<!-- @@@values -->
<!-- $$$values$$$valuesconstKey& -->
<h3 class="fn" id="values-1"><a name="values-1"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">T</span>&gt; QMap::<span class="name">values</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Returns a list containing all the values associated with key <i>key</i>, from the most recently inserted to the least recently inserted one.</p>
<p><b>See also </b><a href="qmap.html#count-1">count</a>() and <a href="qmap.html#insertMulti">insertMulti</a>().</p>
<!-- @@@values -->
<!-- $$$operator!=[overload1]$$$operator!=constQMap<Key,T>& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QMap::<span class="name">operator!=</span>(const <span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if <i>other</i> is not equal to this map; otherwise returns <code>false</code>.</p>
<p>Two maps are considered equal if they contain the same (key, value) pairs.</p>
<p>This function requires the value type to implement <code>operator==()</code>.</p>
<p><b>See also </b><a href="qmap.html#operator-eq-eq">operator==</a>().</p>
<!-- @@@operator!= -->
<!-- $$$operator=[overload1]$$$operator=constQMap<Key,T>& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;QMap::<span class="name">operator=</span>(const <span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>other</i>)</h3>
<p>Assigns <i>other</i> to this map and returns a reference to this map.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=QMap<Key,T>&& -->
<h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;QMap::<span class="name">operator=</span>(<span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;&amp;<i>other</i>)</h3>
<p>Move-assigns <i>other</i> to this <a href="qmap.html">QMap</a> instance.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@operator= -->
<!-- $$$operator==[overload1]$$$operator==constQMap<Key,T>& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QMap::<span class="name">operator==</span>(const <span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if <i>other</i> is equal to this map; otherwise returns false.</p>
<p>Two maps are considered equal if they contain the same (key, value) pairs.</p>
<p>This function requires the value type to implement <code>operator==()</code>.</p>
<p><b>See also </b><a href="qmap.html#operator-not-eq">operator!=</a>().</p>
<!-- @@@operator== -->
<!-- $$$operator[][overload1]$$$operator[]constKey& -->
<h3 class="fn" id="operator-5b-5d"><a name="operator-5b-5d"></a><span class="type">T</span> &amp;QMap::<span class="name">operator[]</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Returns the value associated with the key <i>key</i> as a modifiable reference.</p>
<p>If the map contains no item with key <i>key</i>, the function inserts a <a href="containers.html#default-constructed-value">default-constructed value</a> into the map with key <i>key</i>, and returns a reference to it. If the map contains multiple items with key <i>key</i>, this function returns a reference to the most recently inserted value.</p>
<p><b>See also </b><a href="qmap.html#insert">insert</a>() and <a href="qmap.html#value">value</a>().</p>
<!-- @@@operator[] -->
<!-- $$$operator[]$$$operator[]constKey& -->
<h3 class="fn" id="operator-5b-5d-1"><a name="operator-5b-5d-1"></a>const <span class="type">T</span> QMap::<span class="name">operator[]</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Same as <a href="qmap.html#value">value</a>().</p>
<!-- @@@operator[] -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQMap<Key,T>& -->
<h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&lt;&lt;</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>out</i>, const <span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>map</i>)</h3>
<p>Writes the map <i>map</i> to stream <i>out</i>.</p>
<p>This function requires the key and value types to implement <code>operator&lt;&lt;()</code>.</p>
<p><b>See also </b><a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QMap<Key,T>& -->
<h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&gt;&gt;</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>in</i>, <span class="type"><a href="qmap.html#QMap">QMap</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>map</i>)</h3>
<p>Reads a map from stream <i>in</i> into <i>map</i>.</p>
<p>This function requires the key and value types to implement <code>operator&gt;&gt;()</code>.</p>
<p><b>See also </b><a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<!-- @@@operator>> -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>