Sophie

Sophie

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

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" />
<!-- qhash.cpp -->
  <title>QHash 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 >QHash</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>
<li class="level2"><a href="#the-qhash-hashing-function">The qHash() hashing function</a></li>
<li class="level2"><a href="#algorithmic-complexity-attacks">Algorithmic complexity attacks</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QHash Class</h1>
<!-- $$$QHash-brief -->
<p>The <a href="qhash.html#qhash">QHash</a> class is a template class that provides a hash-table-based dictionary. <a href="#details">More...</a></p>
<!-- @@@QHash -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QHash&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="qmultihash.html">QMultiHash</a></p>
</td></tr></table></div><ul>
<li><a href="qhash-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="qhash-const-iterator.html">const_iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qhash-iterator.html">iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qhash-key-iterator.html">key_iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#ConstIterator-typedef">ConstIterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#Iterator-typedef">Iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qhash.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="qhash.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="qhash.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="qhash.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="qhash.html#QHash">QHash</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#QHash-1">QHash</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="qhash.html#QHash-2">QHash</a></b>(const QHash &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#QHash-3">QHash</a></b>(QHash &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#dtor.QHash">~QHash</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#begin">begin</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#begin-1">begin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#capacity">capacity</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#cbegin">cbegin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#cend">cend</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#clear">clear</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#constBegin">constBegin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#constEnd">constEnd</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.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="qhash.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="qhash.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="qhash.html#count-1">count</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#empty">empty</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#end">end</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.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="qhash.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="qhash.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="qhash.html#erase">erase</a></b>(const_iterator <i>pos</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#erase-1">erase</a></b>(iterator <i>pos</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.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="qhash.html#find-1">find</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="qhash.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="qhash.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"> bool </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#isEmpty">isEmpty</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const Key </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#key">key</a></b>(const T &amp;<i>value</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const Key </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#key-1">key</a></b>(const T &amp;<i>value</i>, const Key &amp;<i>defaultKey</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> key_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#keyBegin">keyBegin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> key_iterator </td><td class="memItemRight bottomAlign"><b><a href="qhash.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="qhash.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="qhash.html#keys-1">keys</a></b>(const T &amp;<i>value</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#remove">remove</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#reserve">reserve</a></b>(int <i>size</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#size">size</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#squeeze">squeeze</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#swap">swap</a></b>(QHash &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#take">take</a></b>(const Key &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;Key&gt; </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#uniqueKeys">uniqueKeys</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QHash &amp;</td><td class="memItemRight bottomAlign"><b><a href="qhash.html#unite">unite</a></b>(const QHash &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#value">value</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="qhash.html#value-1">value</a></b>(const Key &amp;<i>key</i>, const T &amp;<i>defaultValue</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;T&gt; </td><td class="memItemRight bottomAlign"><b><a href="qhash.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="qhash.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="qhash.html#operator-not-eq">operator!=</a></b>(const QHash &amp;<i>other</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QHash &amp;</td><td class="memItemRight bottomAlign"><b><a href="qhash.html#operator-eq">operator=</a></b>(const QHash &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QHash &amp;</td><td class="memItemRight bottomAlign"><b><a href="qhash.html#operator-eq-1">operator=</a></b>(QHash &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#operator-eq-eq">operator==</a></b>(const QHash &amp;<i>other</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T &amp;</td><td class="memItemRight bottomAlign"><b><a href="qhash.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="qhash.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"> int </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qGlobalQHashSeed">qGlobalQHashSeed</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHashx">qHash</a></b>(const QUrl &amp;<i>url</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-1x">qHash</a></b>(const QDateTime &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-2x">qHash</a></b>(const QDate &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-3x">qHash</a></b>(const QTime &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-4">qHash</a></b>(const QPair&lt;T1, T2&gt; &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-5">qHash</a></b>(const std::pair&lt;T1, T2&gt; &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-6">qHash</a></b>(char <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-7">qHash</a></b>(uchar <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-8">qHash</a></b>(signed char <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-9">qHash</a></b>(ushort <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-10">qHash</a></b>(short <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-11">qHash</a></b>(uint <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-12">qHash</a></b>(int <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-13">qHash</a></b>(ulong <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-14">qHash</a></b>(long <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-15">qHash</a></b>(quint64 <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-16">qHash</a></b>(qint64 <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-17">qHash</a></b>(float <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-18">qHash</a></b>(double <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-19">qHash</a></b>(const QChar <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-20">qHash</a></b>(const QByteArray &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-21">qHash</a></b>(const QBitArray &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-22">qHash</a></b>(const QString &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-23">qHash</a></b>(const QStringRef &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-24">qHash</a></b>(QLatin1String <i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-25">qHash</a></b>(const T *<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-26">qHash</a></b>(const QHash&lt;Key, T&gt; &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-27">qHash</a></b>(const QSet&lt;T&gt; &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHash-28">qHash</a></b>(const QVersionNumber &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="../qtnetwork/qhash.html#qHash-2">qHash</a></b>(const QSslCertificate &amp;<i>key</i>, uint <i>seed</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="../qtnetwork/qhash.html#qHash-4">qHash</a></b>(QSslEllipticCurve <i>curve</i>, uint <i>seed</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="../qtnetwork/qhash.html#qHash-6">qHash</a></b>(const QSslError &amp;<i>key</i>, uint <i>seed</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHashBits">qHashBits</a></b>(const void *<i>p</i>, size_t <i>len</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHashRange">qHashRange</a></b>(InputIterator <i>first</i>, InputIterator <i>last</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qHashRangeCommutative">qHashRangeCommutative</a></b>(InputIterator <i>first</i>, InputIterator <i>last</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhash.html#qSetGlobalQHashSeed">qSetGlobalQHashSeed</a></b>(int <i>newSeed</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qhash.html#operator-lt-lt">operator&lt;&lt;</a></b>(QDataStream &amp;<i>out</i>, const QHash&lt;Key, T&gt; &amp;<i>hash</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qhash.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>in</i>, QHash&lt;Key, T&gt; &amp;<i>hash</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QHash-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qhash.html#qhash">QHash</a> class is a template class that provides a hash-table-based dictionary.</p>
<p><a href="qhash.html#qhash">QHash</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 very fast lookup of the value associated with a key.</p>
<p><a href="qhash.html#qhash">QHash</a> provides very similar functionality to <a href="qmap.html">QMap</a>. The differences are:</p>
<ul>
<li><a href="qhash.html#qhash">QHash</a> provides 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="qmap.html">QMap</a>, the items are always sorted by key. With <a href="qhash.html#qhash">QHash</a>, the items are arbitrarily ordered.</li>
<li>The key type of a <a href="qmap.html">QMap</a> must provide operator&lt;(). The key type of a <a href="qhash.html#qhash">QHash</a> must provide operator==() and a global hash function called <a href="qhash.html#qHashx">qHash</a>() (see <a href="qhash.html#qhash">qHash</a>).</li>
</ul>
<p>Here's an example <a href="qhash.html#qhash">QHash</a> with <a href="qstring.html">QString</a> keys and <code>int</code> values:</p>
<pre class="cpp">

  <span class="type"><a href="qhash.html#QHash">QHash</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> hash;

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

  hash<span class="operator">[</span><span class="string">&quot;one&quot;</span><span class="operator">]</span> <span class="operator">=</span> <span class="number">1</span>;
  hash<span class="operator">[</span><span class="string">&quot;three&quot;</span><span class="operator">]</span> <span class="operator">=</span> <span class="number">3</span>;
  hash<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="qhash.html#qhash">QHash</a>: (&quot;one&quot;, 1), (&quot;three&quot;, 3), and (&quot;seven&quot;, 7). Another way to insert items into the hash is to use <a href="qhash.html#insert">insert</a>():</p>
<pre class="cpp">

  hash<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="qhash.html#value">value</a>():</p>
<pre class="cpp">

  <span class="type">int</span> num1 <span class="operator">=</span> hash<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> hash<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 hash, these functions return a <a href="containers.html#default-constructed-value">default-constructed value</a>.</p>
<p>If you want to check whether the hash contains a particular key, use <a href="qhash.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> (hash<span class="operator">.</span>contains(<span class="string">&quot;TIMEOUT&quot;</span>))
      timeout <span class="operator">=</span> hash<span class="operator">.</span>value(<span class="string">&quot;TIMEOUT&quot;</span>);

</pre>
<p>There is also a <a href="qhash.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> hash<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="qhash.html#contains">contains</a>() and <a href="qhash.html#value">value</a>() rather than operator[]() for looking up a key in a hash. The reason is that operator[]() silently inserts an item into the hash if no item exists with the same key (unless the hash 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="qhash.html#QHash">QHash</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> hash;
  <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> (hash<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>hash[i]</code> with <code>hash.value(i)</code> in the code above.</p>
<p>Internally, <a href="qhash.html#qhash">QHash</a> uses a hash table to perform lookups. Unlike Qt 3's <code>QDict</code> class, which needed to be initialized with a prime number, <a href="qhash.html#qhash">QHash</a>'s hash table automatically grows and shrinks to provide fast lookups without wasting too much memory. You can still control the size of the hash table by calling <a href="qhash.html#reserve">reserve</a>() if you already know approximately how many items the <a href="qhash.html#qhash">QHash</a> will contain, but this isn't necessary to obtain good performance. You can also call <a href="qhash.html#capacity">capacity</a>() to retrieve the hash table's size.</p>
<p>If you want to navigate through all the (key, value) pairs stored in a <a href="qhash.html#qhash">QHash</a>, you can use an iterator. <a href="qhash.html#qhash">QHash</a> provides both <a href="containers.html#java-style-iterators">Java-style iterators</a> (<a href="qhashiterator.html">QHashIterator</a> and <a href="qmutablehashiterator.html">QMutableHashIterator</a>) and <a href="containers.html#stl-style-iterators">STL-style iterators</a> (<a href="qhash-const-iterator.html">QHash::const_iterator</a> and <a href="qhash-iterator.html">QHash::iterator</a>). Here's how to iterate over a <a href="qhash.html#qhash">QHash</a>&lt;<a href="qstring.html">QString</a>, int&gt; using a Java-style iterator:</p>
<pre class="cpp">

  <span class="type"><a href="qhashiterator.html">QHashIterator</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(hash);
  <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:</p>
<pre class="cpp">

  <span class="type"><a href="qhash.html#QHash">QHash</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> hash<span class="operator">.</span>constBegin();
  <span class="keyword">while</span> (i <span class="operator">!</span><span class="operator">=</span> hash<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><a href="qhash.html#qhash">QHash</a> is unordered, so an iterator's sequence cannot be assumed to be predictable. If ordering by key is required, use a <a href="qmap.html">QMap</a>.</p>
<p>Normally, a <a href="qhash.html#qhash">QHash</a> allows only one value per key. If you call <a href="qhash.html#insert">insert</a>() with a key that already exists in the <a href="qhash.html#qhash">QHash</a>, the previous value is erased. For example:</p>
<pre class="cpp">

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

</pre>
<p>However, you can store multiple values per key by using <a href="qhash.html#insertMulti">insertMulti</a>() instead of <a href="qhash.html#insert">insert</a>() (or using the convenience subclass <a href="qmultihash.html">QMultiHash</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> hash<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. A more efficient approach is to call <a href="qhash.html#find">find</a>() to get the iterator for the first item with a key and iterate from there:</p>
<pre class="cpp">

  <span class="type"><a href="qhash.html#QHash">QHash</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> hash<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> hash<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 hash (not the keys), you can also use <a href="containers.html#foreach">foreach</a>:</p>
<pre class="cpp">

  <span class="type"><a href="qhash.html#QHash">QHash</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> hash;
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  foreach (<span class="type">int</span> value<span class="operator">,</span> hash)
      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 hash in several ways. One way is to call <a href="qhash.html#remove">remove</a>(); this will remove any item with the given key. Another way is to use <a href="qmutablehashiterator.html#remove">QMutableHashIterator::remove</a>(). In addition, you can clear the entire hash using <a href="qhash.html#clear">clear</a>().</p>
<p><a href="qhash.html#qhash">QHash</a>'s key and value data types must be <a href="containers.html#assignable-data-types">assignable data types</a>. You cannot, for example, store a <a href="../qtwidgets/qwidget.html">QWidget</a> as a value; instead, store a <a href="../qtwidgets/qwidget.html">QWidget</a> *.</p>
<a name="qhash"></a><a name="the-qhash-hashing-function"></a>
<h4 >The qHash() hashing function</h4>
<p>A <a href="qhash.html#qhash">QHash</a>'s key type has additional requirements other than being an assignable data type: it must provide operator==(), and there must also be a <a href="qhash.html#qHashx">qHash</a>() function in the type's namespace that returns a hash value for an argument of the key's type.</p>
<p>The <a href="qhash.html#qHashx">qHash</a>() function computes a numeric value based on a key. It can use any algorithm imaginable, as long as it always returns the same value if given the same argument. In other words, if <code>e1 == e2</code>, then <code>qHash(e1) == qHash(e2)</code> must hold as well. However, to obtain good performance, the <a href="qhash.html#qHashx">qHash</a>() function should attempt to return different hash values for different keys to the largest extent possible.</p>
<p>For a key type <code>K</code>, the <a href="qhash.html#qhash">qHash</a> function must have one of these signatures:</p>
<pre class="cpp">

  <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <a href="qhash.html#qHashx">qHash</a>(K key);
  <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <a href="qhash.html#qHashx">qHash</a>(<span class="keyword">const</span> K <span class="operator">&amp;</span>key);

  <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <a href="qhash.html#qHashx">qHash</a>(K key<span class="operator">,</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> seed);
  <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <a href="qhash.html#qHashx">qHash</a>(<span class="keyword">const</span> K <span class="operator">&amp;</span>key<span class="operator">,</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> seed);

</pre>
<p>The two-arguments overloads take an unsigned integer that should be used to seed the calculation of the hash function. This seed is provided by <a href="qhash.html#qhash">QHash</a> in order to prevent a family of <a href="qhash.html#algorithmic-complexity-attacks">algorithmic complexity attacks</a>. If both a one-argument and a two-arguments overload are defined for a key type, the latter is used by <a href="qhash.html#qhash">QHash</a> (note that you can simply define a two-arguments version, and use a default value for the seed parameter).</p>
<p>Here's a partial list of the C++ and Qt types that can serve as keys in a <a href="qhash.html#qhash">QHash</a>: any integer type (char, unsigned long, etc.), any pointer type, <a href="qchar.html">QChar</a>, <a href="qstring.html">QString</a>, and <a href="qbytearray.html">QByteArray</a>. For all of these, the <code>&lt;QHash&gt;</code> header defines a <a href="qhash.html#qHashx">qHash</a>() function that computes an adequate hash value. Many other Qt classes also declare a <a href="qhash.html#qhash">qHash</a> overload for their type; please refer to the documentation of each class.</p>
<p>If you want to use other types as the key, make sure that you provide operator==() and a <a href="qhash.html#qHashx">qHash</a>() implementation.</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">=</span><span class="operator">=</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">return</span> e1<span class="operator">.</span>name() <span class="operator">=</span><span class="operator">=</span> e2<span class="operator">.</span>name()
             <span class="operator">&amp;</span><span class="operator">&amp;</span> e1<span class="operator">.</span>dateOfBirth() <span class="operator">=</span><span class="operator">=</span> e2<span class="operator">.</span>dateOfBirth();
  }

  <span class="keyword">inline</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <a href="qhash.html#qHashx">qHash</a>(<span class="keyword">const</span> Employee <span class="operator">&amp;</span>key<span class="operator">,</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> seed)
  {
      <span class="keyword">return</span> <a href="qhash.html#qHashx">qHash</a>(key<span class="operator">.</span>name()<span class="operator">,</span> seed) <span class="operator">^</span> key<span class="operator">.</span>dateOfBirth()<span class="operator">.</span>day();
  }

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

</pre>
<p>In the example above, we've relied on Qt's global <a href="qhash.html#qhash">qHash</a>(const <a href="qstring.html">QString</a> &amp;, uint) to give us a hash value for the employee's name, and XOR'ed this with the day they were born to help produce unique hashes for people with the same name.</p>
<p>Note that the implementation of the <a href="qhash.html#qHashx">qHash</a>() overloads offered by Qt may change at any time. You <b>must not</b> rely on the fact that <a href="qhash.html#qHashx">qHash</a>() will give the same results (for the same inputs) across different Qt versions.</p>
<a name="algorithmic-complexity-attacks"></a>
<h4 >Algorithmic complexity attacks</h4>
<p>All hash tables are vulnerable to a particular class of denial of service attacks, in which the attacker carefully pre-computes a set of different keys that are going to be hashed in the same bucket of a hash table (or even have the very same hash value). The attack aims at getting the worst-case algorithmic behavior (O(n) instead of amortized O(1), see <a href="containers.html#algorithmic-complexity">Algorithmic Complexity</a> for the details) when the data is fed into the table.</p>
<p>In order to avoid this worst-case behavior, the calculation of the hash value done by <a href="qhash.html#qHashx">qHash</a>() can be salted by a random seed, that nullifies the attack's extent. This seed is automatically generated by <a href="qhash.html#qhash">QHash</a> once per process, and then passed by <a href="qhash.html#qhash">QHash</a> as the second argument of the two-arguments overload of the <a href="qhash.html#qHashx">qHash</a>() function.</p>
<p>This randomization of <a href="qhash.html#qhash">QHash</a> is enabled by default. Even though programs should never depend on a particular <a href="qhash.html#qhash">QHash</a> ordering, there may be situations where you temporarily need deterministic behavior, for example for debugging or regression testing. To disable the randomization, define the environment variable <code>QT_HASH_SEED</code>. The contents of that variable, interpreted as a decimal value, will be used as the seed for <a href="qhash.html#qHashx">qHash</a>(). Alternatively, you can call the <a href="qhash.html#qSetGlobalQHashSeed">qSetGlobalQHashSeed</a>() function.</p>
</div>
<p><b>See also </b><a href="qhashiterator.html">QHashIterator</a>, <a href="qmutablehashiterator.html">QMutableHashIterator</a>, <a href="qmap.html">QMap</a>, and <a href="qset.html">QSet</a>.</p>
<!-- @@@QHash -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ConstIterator -->
<h3 class="fn" id="ConstIterator-typedef"><a name="ConstIterator-typedef"></a>typedef QHash::<span class="name">ConstIterator</span></h3>
<p>Qt-style synonym for <a href="qhash-const-iterator.html">QHash::const_iterator</a>.</p>
<!-- @@@ConstIterator -->
<!-- $$$Iterator -->
<h3 class="fn" id="Iterator-typedef"><a name="Iterator-typedef"></a>typedef QHash::<span class="name">Iterator</span></h3>
<p>Qt-style synonym for <a href="qhash-iterator.html">QHash::iterator</a>.</p>
<!-- @@@Iterator -->
<!-- $$$difference_type -->
<h3 class="fn" id="difference_type-typedef"><a name="difference_type-typedef"></a>typedef QHash::<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 QHash::<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 QHash::<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 QHash::<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>
<!-- $$$QHash[overload1]$$$QHash -->
<h3 class="fn" id="QHash"><a name="QHash"></a>QHash::<span class="name">QHash</span>()</h3>
<p>Constructs an empty hash.</p>
<p><b>See also </b><a href="qhash.html#clear">clear</a>().</p>
<!-- @@@QHash -->
<!-- $$$QHash$$$QHashstd::initializer_list<std::pair<Key,T>> -->
<h3 class="fn" id="QHash-1"><a name="QHash-1"></a>QHash::<span class="name">QHash</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 hash 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>
<!-- @@@QHash -->
<!-- $$$QHash$$$QHashconstQHash& -->
<h3 class="fn" id="QHash-2"><a name="QHash-2"></a>QHash::<span class="name">QHash</span>(const <span class="type"><a href="qhash.html#QHash">QHash</a></span> &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="qhash.html#qhash">QHash</a> is <a href="implicit-sharing.html">implicitly shared</a>. This makes returning a <a href="qhash.html#qhash">QHash</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="qhash.html#operator-eq">operator=</a>().</p>
<!-- @@@QHash -->
<!-- $$$QHash$$$QHashQHash&& -->
<h3 class="fn" id="QHash-3"><a name="QHash-3"></a>QHash::<span class="name">QHash</span>(<span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-constructs a <a href="qhash.html#qhash">QHash</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>
<!-- @@@QHash -->
<!-- $$$~QHash[overload1]$$$~QHash -->
<h3 class="fn" id="dtor.QHash"><a name="dtor.QHash"></a>QHash::<span class="name">~QHash</span>()</h3>
<p>Destroys the hash. References to the values in the hash and all iterators of this hash become invalid.</p>
<!-- @@@~QHash -->
<!-- $$$begin[overload1]$$$begin -->
<h3 class="fn" id="begin"><a name="begin"></a><span class="type"><a href="qhash-iterator.html">iterator</a></span> QHash::<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 hash.</p>
<p><b>See also </b><a href="qhash.html#constBegin">constBegin</a>() and <a href="qhash.html#end">end</a>().</p>
<!-- @@@begin -->
<!-- $$$begin$$$begin -->
<h3 class="fn" id="begin-1"><a name="begin-1"></a><span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> QHash::<span class="name">begin</span>() const</h3>
<p>This is an overloaded function.</p>
<!-- @@@begin -->
<!-- $$$capacity[overload1]$$$capacity -->
<h3 class="fn" id="capacity"><a name="capacity"></a><span class="type">int</span> QHash::<span class="name">capacity</span>() const</h3>
<p>Returns the number of buckets in the <a href="qhash.html#qhash">QHash</a>'s internal hash table.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qhash.html#qhash">QHash</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to know how many items are in the hash, call <a href="qhash.html#size">size</a>().</p>
<p><b>See also </b><a href="qhash.html#reserve">reserve</a>() and <a href="qhash.html#squeeze">squeeze</a>().</p>
<!-- @@@capacity -->
<!-- $$$cbegin[overload1]$$$cbegin -->
<h3 class="fn" id="cbegin"><a name="cbegin"></a><span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> QHash::<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 hash.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qhash.html#begin">begin</a>() and <a href="qhash.html#cend">cend</a>().</p>
<!-- @@@cbegin -->
<!-- $$$cend[overload1]$$$cend -->
<h3 class="fn" id="cend"><a name="cend"></a><span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> QHash::<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 hash.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qhash.html#cbegin">cbegin</a>() and <a href="qhash.html#end">end</a>().</p>
<!-- @@@cend -->
<!-- $$$clear[overload1]$$$clear -->
<h3 class="fn" id="clear"><a name="clear"></a><span class="type">void</span> QHash::<span class="name">clear</span>()</h3>
<p>Removes all items from the hash.</p>
<p><b>See also </b><a href="qhash.html#remove">remove</a>().</p>
<!-- @@@clear -->
<!-- $$$constBegin[overload1]$$$constBegin -->
<h3 class="fn" id="constBegin"><a name="constBegin"></a><span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> QHash::<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 hash.</p>
<p><b>See also </b><a href="qhash.html#begin">begin</a>() and <a href="qhash.html#constEnd">constEnd</a>().</p>
<!-- @@@constBegin -->
<!-- $$$constEnd[overload1]$$$constEnd -->
<h3 class="fn" id="constEnd"><a name="constEnd"></a><span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> QHash::<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 hash.</p>
<p><b>See also </b><a href="qhash.html#constBegin">constBegin</a>() and <a href="qhash.html#end">end</a>().</p>
<!-- @@@constEnd -->
<!-- $$$constFind[overload1]$$$constFindconstKey& -->
<h3 class="fn" id="constFind"><a name="constFind"></a><span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> QHash::<span class="name">constFind</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>Returns an iterator pointing to the item with the <i>key</i> in the hash.</p>
<p>If the hash contains no item with the <i>key</i>, the function returns <a href="qhash.html#constEnd">constEnd</a>().</p>
<p>This function was introduced in  Qt 4.1.</p>
<p><b>See also </b><a href="qhash.html#find">find</a>() and <a href="qmultihash.html#constFind">QMultiHash::constFind</a>().</p>
<!-- @@@constFind -->
<!-- $$$contains[overload1]$$$containsconstKey& -->
<h3 class="fn" id="contains"><a name="contains"></a><span class="type">bool</span> QHash::<span class="name">contains</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>Returns <code>true</code> if the hash contains an item with the <i>key</i>; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qhash.html#count-1">count</a>() and <a href="qmultihash.html#contains">QMultiHash::contains</a>().</p>
<!-- @@@contains -->
<!-- $$$count[overload1]$$$countconstKey& -->
<h3 class="fn" id="count"><a name="count"></a><span class="type">int</span> QHash::<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 the <i>key</i>.</p>
<p><b>See also </b><a href="qhash.html#contains">contains</a>() and <a href="qhash.html#insertMulti">insertMulti</a>().</p>
<!-- @@@count -->
<!-- $$$count$$$count -->
<h3 class="fn" id="count-1"><a name="count-1"></a><span class="type">int</span> QHash::<span class="name">count</span>() const</h3>
<p>This is an overloaded function.</p>
<p>Same as <a href="qhash.html#size">size</a>().</p>
<!-- @@@count -->
<!-- $$$empty[overload1]$$$empty -->
<h3 class="fn" id="empty"><a name="empty"></a><span class="type">bool</span> QHash::<span class="name">empty</span>() const</h3>
<p>This function is provided for STL compatibility. It is equivalent to <a href="qhash.html#isEmpty">isEmpty</a>(), returning true if the hash is empty; otherwise returns <code>false</code>.</p>
<!-- @@@empty -->
<!-- $$$end[overload1]$$$end -->
<h3 class="fn" id="end"><a name="end"></a><span class="type"><a href="qhash-iterator.html">iterator</a></span> QHash::<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 hash.</p>
<p><b>See also </b><a href="qhash.html#begin">begin</a>() and <a href="qhash.html#constEnd">constEnd</a>().</p>
<!-- @@@end -->
<!-- $$$end$$$end -->
<h3 class="fn" id="end-1"><a name="end-1"></a><span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> QHash::<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="qhash-iterator.html">iterator</a></span>, <span class="type"><a href="qhash-iterator.html">iterator</a></span>&gt; QHash::<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>. If the range is empty then both iterators will be equal to <a href="qhash.html#end">end</a>().</p>
<p>This function was introduced in  Qt 5.7.</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="qhash-const-iterator.html">const_iterator</a></span>, <span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span>&gt; QHash::<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.7.</p>
<!-- @@@equal_range -->
<!-- $$$erase[overload1]$$$eraseconst_iterator -->
<h3 class="fn" id="erase"><a name="erase"></a><span class="type"><a href="qhash-iterator.html">iterator</a></span> QHash::<span class="name">erase</span>(<span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> <i>pos</i>)</h3>
<p>Removes the (key, value) pair associated with the iterator <i>pos</i> from the hash, and returns an iterator to the next item in the hash.</p>
<p>Unlike <a href="qhash.html#remove">remove</a>() and <a href="qhash.html#take">take</a>(), this function never causes <a href="qhash.html#qhash">QHash</a> to rehash its internal data structure. This means that it can safely be called while iterating, and won't affect the order of items in the hash. For example:</p>
<pre class="cpp">

  <span class="type"><a href="qhash.html#QHash">QHash</a></span><span class="operator">&lt;</span><span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span><span class="operator">,</span> <span class="type">int</span><span class="operator">&gt;</span> objectHash;
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="qhash.html#QHash">QHash</a></span><span class="operator">&lt;</span><span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</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> objectHash<span class="operator">.</span>find(obj);
  <span class="keyword">while</span> (i <span class="operator">!</span><span class="operator">=</span> objectHash<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> obj) {
      <span class="keyword">if</span> (i<span class="operator">.</span>value() <span class="operator">=</span><span class="operator">=</span> <span class="number">0</span>) {
          i <span class="operator">=</span> objectHash<span class="operator">.</span>erase(i);
      } <span class="keyword">else</span> {
          <span class="operator">+</span><span class="operator">+</span>i;
      }
  }

</pre>
<p>This function was introduced in  Qt 5.7.</p>
<p><b>See also </b><a href="qhash.html#remove">remove</a>(), <a href="qhash.html#take">take</a>(), and <a href="qhash.html#find">find</a>().</p>
<!-- @@@erase -->
<!-- $$$erase$$$eraseiterator -->
<h3 class="fn" id="erase-1"><a name="erase-1"></a><span class="type"><a href="qhash-iterator.html">iterator</a></span> QHash::<span class="name">erase</span>(<span class="type"><a href="qhash-iterator.html">iterator</a></span> <i>pos</i>)</h3>
<p>This is an overloaded function.</p>
<!-- @@@erase -->
<!-- $$$find[overload1]$$$findconstKey& -->
<h3 class="fn" id="find"><a name="find"></a><span class="type"><a href="qhash-iterator.html">iterator</a></span> QHash::<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 the <i>key</i> in the hash.</p>
<p>If the hash contains no item with the <i>key</i>, the function returns <a href="qhash.html#end">end</a>().</p>
<p>If the hash contains multiple items with the <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="qhash.html#QHash">QHash</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> hash;
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="qhash.html#QHash">QHash</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> hash<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> hash<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="qhash.html#value">value</a>(), <a href="qhash.html#values">values</a>(), and <a href="qmultihash.html#find">QMultiHash::find</a>().</p>
<!-- @@@find -->
<!-- $$$find$$$findconstKey& -->
<h3 class="fn" id="find-1"><a name="find-1"></a><span class="type"><a href="qhash-const-iterator.html">const_iterator</a></span> QHash::<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 -->
<!-- $$$insert[overload1]$$$insertconstKey&constT& -->
<h3 class="fn" id="insert"><a name="insert"></a><span class="type"><a href="qhash-iterator.html">iterator</a></span> QHash::<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 <i>key</i> and a value of <i>value</i>.</p>
<p>If there is already an item with the <i>key</i>, that item's value is replaced with <i>value</i>.</p>
<p>If there are multiple items with the <i>key</i>, the most recently inserted item's value is replaced with <i>value</i>.</p>
<p><b>See also </b><a href="qhash.html#insertMulti">insertMulti</a>().</p>
<!-- @@@insert -->
<!-- $$$insertMulti[overload1]$$$insertMulticonstKey&constT& -->
<h3 class="fn" id="insertMulti"><a name="insertMulti"></a><span class="type"><a href="qhash-iterator.html">iterator</a></span> QHash::<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 <i>key</i> and a value of <i>value</i>.</p>
<p>If there is already an item with the same key in the hash, this function will simply create a new one. (This behavior is different from <a href="qhash.html#insert">insert</a>(), which overwrites the value of an existing item.)</p>
<p><b>See also </b><a href="qhash.html#insert">insert</a>() and <a href="qhash.html#values">values</a>().</p>
<!-- @@@insertMulti -->
<!-- $$$isEmpty[overload1]$$$isEmpty -->
<h3 class="fn" id="isEmpty"><a name="isEmpty"></a><span class="type">bool</span> QHash::<span class="name">isEmpty</span>() const</h3>
<p>Returns <code>true</code> if the hash contains no items; otherwise returns false.</p>
<p><b>See also </b><a href="qhash.html#size">size</a>().</p>
<!-- @@@isEmpty -->
<!-- $$$key[overload1]$$$keyconstT& -->
<h3 class="fn" id="key"><a name="key"></a>const <span class="type">Key</span> QHash::<span class="name">key</span>(const <span class="type">T</span> &amp;<i>value</i>) const</h3>
<p>Returns the first key mapped to <i>value</i>.</p>
<p>If the hash contains no item with the <i>value</i>, 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="qhash.html#qhash">QHash</a>'s internal data structure is optimized for fast lookup by key, not by value.</p>
<p><b>See also </b><a href="qhash.html#value">value</a>() and <a href="qhash.html#keys">keys</a>().</p>
<!-- @@@key -->
<!-- $$$key$$$keyconstT&constKey& -->
<h3 class="fn" id="key-1"><a name="key-1"></a>const <span class="type">Key</span> QHash::<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>) const</h3>
<p>This is an overloaded function.</p>
<p>Returns the first key mapped to <i>value</i>, or <i>defaultKey</i> if the hash contains no item mapped to <i>value</i>.</p>
<p>This function can be slow (<a href="containers.html#linear-time">linear time</a>), because <a href="qhash.html#qhash">QHash</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>
<!-- @@@key -->
<!-- $$$keyBegin[overload1]$$$keyBegin -->
<h3 class="fn" id="keyBegin"><a name="keyBegin"></a><span class="type"><a href="qhash-key-iterator.html">key_iterator</a></span> QHash::<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 hash.</p>
<p>This function was introduced in  Qt 5.6.</p>
<p><b>See also </b><a href="qhash.html#keyEnd">keyEnd</a>().</p>
<!-- @@@keyBegin -->
<!-- $$$keyEnd[overload1]$$$keyEnd -->
<h3 class="fn" id="keyEnd"><a name="keyEnd"></a><span class="type"><a href="qhash-key-iterator.html">key_iterator</a></span> QHash::<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 hash.</p>
<p>This function was introduced in  Qt 5.6.</p>
<p><b>See also </b><a href="qhash.html#keyBegin">keyBegin</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; QHash::<span class="name">keys</span>() const</h3>
<p>Returns a list containing all the keys in the hash, in an arbitrary order. Keys that occur multiple times in the hash (because items were inserted with <a href="qhash.html#insertMulti">insertMulti</a>(), or <a href="qhash.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="qhash.html#uniqueKeys">uniqueKeys</a>().</p>
<p>The order is guaranteed to be the same as that used by <a href="qhash.html#values">values</a>().</p>
<p><b>See also </b><a href="qhash.html#uniqueKeys">uniqueKeys</a>(), <a href="qhash.html#values">values</a>(), and <a href="qhash.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; QHash::<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 an arbitrary order.</p>
<p>This function can be slow (<a href="containers.html#linear-time">linear time</a>), because <a href="qhash.html#qhash">QHash</a>'s internal data structure is optimized for fast lookup by key, not by value.</p>
<!-- @@@keys -->
<!-- $$$remove[overload1]$$$removeconstKey& -->
<h3 class="fn" id="remove"><a name="remove"></a><span class="type">int</span> QHash::<span class="name">remove</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Removes all the items that have the <i>key</i> from the hash. Returns the number of items removed which is usually 1 but will be 0 if the key isn't in the hash, or greater than 1 if <a href="qhash.html#insertMulti">insertMulti</a>() has been used with the <i>key</i>.</p>
<p><b>See also </b><a href="qhash.html#clear">clear</a>(), <a href="qhash.html#take">take</a>(), and <a href="qmultihash.html#remove">QMultiHash::remove</a>().</p>
<!-- @@@remove -->
<!-- $$$reserve[overload1]$$$reserveint -->
<h3 class="fn" id="reserve"><a name="reserve"></a><span class="type">void</span> QHash::<span class="name">reserve</span>(<span class="type">int</span> <i>size</i>)</h3>
<p>Ensures that the <a href="qhash.html#qhash">QHash</a>'s internal hash table consists of at least <i>size</i> buckets.</p>
<p>This function is useful for code that needs to build a huge hash and wants to avoid repeated reallocation. For example:</p>
<pre class="cpp">

  <span class="type"><a href="qhash.html#QHash">QHash</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> hash;
  hash<span class="operator">.</span>reserve(<span class="number">20000</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">20000</span>; <span class="operator">+</span><span class="operator">+</span>i)
      hash<span class="operator">.</span>insert(keys<span class="operator">[</span>i<span class="operator">]</span><span class="operator">,</span> values<span class="operator">[</span>i<span class="operator">]</span>);

</pre>
<p>Ideally, <i>size</i> should be slightly more than the maximum number of items expected in the hash. <i>size</i> doesn't have to be prime, because <a href="qhash.html#qhash">QHash</a> will use a prime number internally anyway. If <i>size</i> is an underestimate, the worst that will happen is that the <a href="qhash.html#qhash">QHash</a> will be a bit slower.</p>
<p>In general, you will rarely ever need to call this function. <a href="qhash.html#qhash">QHash</a>'s internal hash table automatically shrinks or grows to provide good performance without wasting too much memory.</p>
<p><b>See also </b><a href="qhash.html#squeeze">squeeze</a>() and <a href="qhash.html#capacity">capacity</a>().</p>
<!-- @@@reserve -->
<!-- $$$size[overload1]$$$size -->
<h3 class="fn" id="size"><a name="size"></a><span class="type">int</span> QHash::<span class="name">size</span>() const</h3>
<p>Returns the number of items in the hash.</p>
<p><b>See also </b><a href="qhash.html#isEmpty">isEmpty</a>() and <a href="qhash.html#count-1">count</a>().</p>
<!-- @@@size -->
<!-- $$$squeeze[overload1]$$$squeeze -->
<h3 class="fn" id="squeeze"><a name="squeeze"></a><span class="type">void</span> QHash::<span class="name">squeeze</span>()</h3>
<p>Reduces the size of the <a href="qhash.html#qhash">QHash</a>'s internal hash table to save memory.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qhash.html#qhash">QHash</a>'s memory usage. In general, you will rarely ever need to call this function.</p>
<p><b>See also </b><a href="qhash.html#reserve">reserve</a>() and <a href="qhash.html#capacity">capacity</a>().</p>
<!-- @@@squeeze -->
<!-- $$$swap[overload1]$$$swapQHash& -->
<h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QHash::<span class="name">swap</span>(<span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;<i>other</i>)</h3>
<p>Swaps hash <i>other</i> with this hash. 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> QHash::<span class="name">take</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Removes the item with the <i>key</i> from the hash and returns the value associated with it.</p>
<p>If the item does not exist in the hash, 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 hash, only the most recently inserted one is removed.</p>
<p>If you don't use the return value, <a href="qhash.html#remove">remove</a>() is more efficient.</p>
<p><b>See also </b><a href="qhash.html#remove">remove</a>().</p>
<!-- @@@take -->
<!-- $$$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; QHash::<span class="name">uniqueKeys</span>() const</h3>
<p>Returns a list containing all the keys in the map. Keys that occur multiple times in the map (because items were inserted with <a href="qhash.html#insertMulti">insertMulti</a>(), or <a href="qhash.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="qhash.html#keys">keys</a>() and <a href="qhash.html#values">values</a>().</p>
<!-- @@@uniqueKeys -->
<!-- $$$unite[overload1]$$$uniteconstQHash& -->
<h3 class="fn" id="unite"><a name="unite"></a><span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;QHash::<span class="name">unite</span>(const <span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;<i>other</i>)</h3>
<p>Inserts all the items in the <i>other</i> hash into this hash. If a key is common to both hashes, the resulting hash will contain the key multiple times.</p>
<p><b>See also </b><a href="qhash.html#insertMulti">insertMulti</a>().</p>
<!-- @@@unite -->
<!-- $$$value[overload1]$$$valueconstKey& -->
<h3 class="fn" id="value"><a name="value"></a>const <span class="type">T</span> QHash::<span class="name">value</span>(const <span class="type">Key</span> &amp;<i>key</i>) const</h3>
<p>Returns the value associated with the <i>key</i>.</p>
<p>If the hash contains no item with the <i>key</i>, the function returns a <a href="containers.html#default-constructed-value">default-constructed value</a>. If there are multiple items for the <i>key</i> in the hash, the value of the most recently inserted one is returned.</p>
<p><b>See also </b><a href="qhash.html#key">key</a>(), <a href="qhash.html#values">values</a>(), <a href="qhash.html#contains">contains</a>(), and <a href="qhash.html#operator-5b-5d">operator[]</a>().</p>
<!-- @@@value -->
<!-- $$$value$$$valueconstKey&constT& -->
<h3 class="fn" id="value-1"><a name="value-1"></a>const <span class="type">T</span> QHash::<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>) const</h3>
<p>This is an overloaded function.</p>
<p>If the hash contains no item with the given <i>key</i>, the function returns <i>defaultValue</i>.</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; QHash::<span class="name">values</span>() const</h3>
<p>Returns a list containing all the values in the hash, in an arbitrary order. 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>The order is guaranteed to be the same as that used by <a href="qhash.html#keys">keys</a>().</p>
<p><b>See also </b><a href="qhash.html#keys">keys</a>() and <a href="qhash.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; QHash::<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 of all the values associated with the <i>key</i>, from the most recently inserted to the least recently inserted.</p>
<p><b>See also </b><a href="qhash.html#count-1">count</a>() and <a href="qhash.html#insertMulti">insertMulti</a>().</p>
<!-- @@@values -->
<!-- $$$operator!=[overload1]$$$operator!=constQHash& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QHash::<span class="name">operator!=</span>(const <span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if <i>other</i> is not equal to this hash; otherwise returns <code>false</code>.</p>
<p>Two hashes 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="qhash.html#operator-eq-eq">operator==</a>().</p>
<!-- @@@operator!= -->
<!-- $$$operator=[overload1]$$$operator=constQHash& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;QHash::<span class="name">operator=</span>(const <span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;<i>other</i>)</h3>
<p>Assigns <i>other</i> to this hash and returns a reference to this hash.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=QHash&& -->
<h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;QHash::<span class="name">operator=</span>(<span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-assigns <i>other</i> to this <a href="qhash.html#qhash">QHash</a> instance.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@operator= -->
<!-- $$$operator==[overload1]$$$operator==constQHash& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QHash::<span class="name">operator==</span>(const <span class="type"><a href="qhash.html#QHash">QHash</a></span> &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if <i>other</i> is equal to this hash; otherwise returns false.</p>
<p>Two hashes 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="qhash.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;QHash::<span class="name">operator[]</span>(const <span class="type">Key</span> &amp;<i>key</i>)</h3>
<p>Returns the value associated with the <i>key</i> as a modifiable reference.</p>
<p>If the hash contains no item with the <i>key</i>, the function inserts a <a href="containers.html#default-constructed-value">default-constructed value</a> into the hash with the <i>key</i>, and returns a reference to it. If the hash contains multiple items with the <i>key</i>, this function returns a reference to the most recently inserted value.</p>
<p><b>See also </b><a href="qhash.html#insert">insert</a>() and <a href="qhash.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> QHash::<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="qhash.html#value">value</a>().</p>
<!-- @@@operator[] -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$qGlobalQHashSeed[overload1]$$$qGlobalQHashSeed -->
<h3 class="fn" id="qGlobalQHashSeed"><a name="qGlobalQHashSeed"></a><span class="type">int</span> <span class="name">qGlobalQHashSeed</span>()</h3>
<p>Returns the current global <a href="qhash.html#qhash">QHash</a> seed.</p>
<p>The seed is set in any newly created <a href="qhash.html#qhash">QHash</a>. See <a href="qhash.html#qhash">qHash</a> about how this seed is being used by <a href="qhash.html#qhash">QHash</a>.</p>
<p>This function was introduced in  Qt 5.6.</p>
<p><b>See also </b><a href="qhash.html#qSetGlobalQHashSeed">qSetGlobalQHashSeed</a>.</p>
<!-- @@@qGlobalQHashSeed -->
<!-- $$$qHash[overload1]$$$qHashconstQUrl&uint -->
<h3 class="fn" id="qHashx"><a name="qHashx"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qurl.html">QUrl</a></span> &amp;<i>url</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>url</i>. If specified, <i>seed</i> is used to initialize the hash.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQDateTime&uint -->
<h3 class="fn" id="qHash-1x"><a name="qHash-1x"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qdatetime.html">QDateTime</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQDate&uint -->
<h3 class="fn" id="qHash-2x"><a name="qHash-2x"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qdate.html">QDate</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQTime&uint -->
<h3 class="fn" id="qHash-3x"><a name="qHash-3x"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qtime.html">QTime</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQPair<T1,T2>&uint -->
<h3 class="fn" id="qHash-4"><a name="qHash-4"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qpair.html">QPair</a></span>&lt;<span class="type">T1</span>, <span class="type">T2</span>&gt; &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>Types <code>T1</code> and <code>T2</code> must be supported by <a href="qhash.html#qHashx">qHash</a>().</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconststd::pair<T1,T2>&uint -->
<h3 class="fn" id="qHash-5"><a name="qHash-5"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type">std::pair</span>&lt;<span class="type">T1</span>, <span class="type">T2</span>&gt; &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>Types <code>T1</code> and <code>T2</code> must be supported by <a href="qhash.html#qHashx">qHash</a>().</p>
<p><b>Note: </b>The return type of this function is <i>not</i> the same as that of</p><pre class="cpp">

  <a href="qhash.html#qHashx">qHash</a>(<a href="qpair.html#qMakePair">qMakePair</a>(key<span class="operator">.</span>first<span class="operator">,</span> key<span class="operator">.</span>second)<span class="operator">,</span> seed);

</pre>
<p>The two functions use different hashing algorithms; due to binary compatibility constraints, we cannot change the <a href="qpair.html">QPair</a> algorithm to match the std::pair one before Qt 6.</p>
<p>This function was introduced in  Qt 5.7.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashcharuint -->
<h3 class="fn" id="qHash-6"><a name="qHash-6"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type">char</span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashucharuint -->
<h3 class="fn" id="qHash-7"><a name="qHash-7"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type"><a href="qtglobal.html#uchar-typedef">uchar</a></span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashsignedcharuint -->
<h3 class="fn" id="qHash-8"><a name="qHash-8"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type">signed</span> <span class="type">char</span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashushortuint -->
<h3 class="fn" id="qHash-9"><a name="qHash-9"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type"><a href="qtglobal.html#ushort-typedef">ushort</a></span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashshortuint -->
<h3 class="fn" id="qHash-10"><a name="qHash-10"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type">short</span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashuintuint -->
<h3 class="fn" id="qHash-11"><a name="qHash-11"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashintuint -->
<h3 class="fn" id="qHash-12"><a name="qHash-12"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type">int</span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashulonguint -->
<h3 class="fn" id="qHash-13"><a name="qHash-13"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type"><a href="qtglobal.html#ulong-typedef">ulong</a></span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashlonguint -->
<h3 class="fn" id="qHash-14"><a name="qHash-14"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type">long</span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashquint64uint -->
<h3 class="fn" id="qHash-15"><a name="qHash-15"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type"><a href="qtglobal.html#quint64-typedef">quint64</a></span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashqint64uint -->
<h3 class="fn" id="qHash-16"><a name="qHash-16"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashfloatuint -->
<h3 class="fn" id="qHash-17"><a name="qHash-17"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type">float</span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.3.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashdoubleuint -->
<h3 class="fn" id="qHash-18"><a name="qHash-18"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type">double</span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.3.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQCharuint -->
<h3 class="fn" id="qHash-19"><a name="qHash-19"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qchar.html">QChar</a></span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQByteArray&uint -->
<h3 class="fn" id="qHash-20"><a name="qHash-20"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQBitArray&uint -->
<h3 class="fn" id="qHash-21"><a name="qHash-21"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qbitarray.html">QBitArray</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQString&uint -->
<h3 class="fn" id="qHash-22"><a name="qHash-22"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQStringRef&uint -->
<h3 class="fn" id="qHash-23"><a name="qHash-23"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qstringref.html">QStringRef</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashQLatin1Stringuint -->
<h3 class="fn" id="qHash-24"><a name="qHash-24"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(<span class="type"><a href="qlatin1string.html">QLatin1String</a></span> <i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstT*uint -->
<h3 class="fn" id="qHash-25"><a name="qHash-25"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type">T</span> *<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQHash<Key,T>&uint -->
<h3 class="fn" id="qHash-26"><a name="qHash-26"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qhash.html#QHash">QHash</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>Type <code>T</code> must be supported by <a href="qhash.html#qHashx">qHash</a>().</p>
<p>This function was introduced in  Qt 5.8.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQSet<T>&uint -->
<h3 class="fn" id="qHash-27"><a name="qHash-27"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qset.html">QSet</a></span>&lt;<span class="type">T</span>&gt; &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>The hash value is independent of the order of elements in <i>key</i>, that is, sets that contain the same elements hash to the same value.</p>
<p>This function was introduced in  Qt 5.5.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQVersionNumber&uint -->
<h3 class="fn" id="qHash-28"><a name="qHash-28"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qversionnumber.html">QVersionNumber</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQSslCertificate&uint -->
<h3 class="fn" id="qHash-29"><a name="qHash-29"></a><span class="name">qHash</span>(const <span class="type"><a href="../qtnetwork/qsslcertificate.html">QSslCertificate</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i>)</h3>
<p>This function was introduced in  Qt 5.4.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashQSslEllipticCurveuint -->
<h3 class="fn" id="qHash-30"><a name="qHash-30"></a><span class="name">qHash</span>(<span class="type"><a href="../qtnetwork/qsslellipticcurve.html">QSslEllipticCurve</a></span> <i>curve</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i>)</h3>
<p>This function was introduced in  Qt 5.5.</p>
<!-- @@@qHash -->
<!-- $$$qHash$$$qHashconstQSslError&uint -->
<h3 class="fn" id="qHash-31"><a name="qHash-31"></a><span class="name">qHash</span>(const <span class="type"><a href="../qtnetwork/qsslerror.html">QSslError</a></span> &amp;<i>key</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i>)</h3>
<p>This function was introduced in  Qt 5.4.</p>
<!-- @@@qHash -->
<!-- $$$qHashBits[overload1]$$$qHashBitsconstvoid*size_tuint -->
<h3 class="fn" id="qHashBits"><a name="qHashBits"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHashBits</span>(const <span class="type">void</span> *<i>p</i>, <span class="type">size_t</span> <i>len</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the memory block of size <i>len</i> pointed to by <i>p</i>, using <i>seed</i> to seed the calculation.</p>
<p>Use this function only to implement <a href="qhash.html#qHashx">qHash</a>() for your own custom types. For example, here's how you could implement a <a href="qhash.html#qHashx">qHash</a>() overload for std::vector&lt;int&gt;:</p>
<pre class="cpp">

  <span class="keyword">inline</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <a href="qhash.html#qHashx">qHash</a>(<span class="keyword">const</span> std<span class="operator">::</span>vector<span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> <span class="operator">&amp;</span>key<span class="operator">,</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> seed <span class="operator">=</span> <span class="number">0</span>)
  {
      <span class="keyword">if</span> (key<span class="operator">.</span>empty())
          <span class="keyword">return</span> seed;
      <span class="keyword">else</span>
          <span class="keyword">return</span> qHashBits(<span class="operator">&amp;</span>key<span class="operator">.</span>front()<span class="operator">,</span> key<span class="operator">.</span>size() <span class="operator">*</span> <span class="keyword">sizeof</span>(<span class="type">int</span>)<span class="operator">,</span> seed);
  }

</pre>
<p>This takes advantage of the fact that std::vector lays out its data contiguously. If that is not the case, or the contained type has padding, you should use <a href="qhash.html#qHashRange">qHashRange</a>() instead.</p>
<p>It bears repeating that the implementation of qHashBits() - like the <a href="qhash.html#qHashx">qHash</a>() overloads offered by Qt - may change at any time. You <b>must not</b> rely on the fact that qHashBits() will give the same results (for the same inputs) across different Qt versions.</p>
<p>This function was introduced in  Qt 5.4.</p>
<p><b>See also </b><a href="qhash.html#qHashRange">qHashRange</a>() and <a href="qhash.html#qHashRangeCommutative">qHashRangeCommutative</a>().</p>
<!-- @@@qHashBits -->
<!-- $$$qHashRange[overload1]$$$qHashRangeInputIteratorInputIteratoruint -->
<h3 class="fn" id="qHashRange"><a name="qHashRange"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHashRange</span>(<span class="type">InputIterator</span> <i>first</i>, <span class="type">InputIterator</span> <i>last</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the range [<i>first</i>,<i>last</i>), using <i>seed</i> to seed the calculation, by successively applying <a href="qhash.html#qHashx">qHash</a>() to each element and combining the hash values into a single one.</p>
<p>The return value of this function depends on the order of elements in the range. That means that</p>
<pre class="cpp">

  {<span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">2</span>}

</pre>
<p>and</p>
<pre class="cpp">

  {<span class="number">1</span><span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span>}

</pre>
<p>hash to <b>different</b> values. If order does not matter, for example for hash tables, use <a href="qhash.html#qHashRangeCommutative">qHashRangeCommutative</a>() instead. If you are hashing raw memory, use <a href="qhash.html#qHashBits">qHashBits</a>().</p>
<p>Use this function only to implement <a href="qhash.html#qHashx">qHash</a>() for your own custom types. For example, here's how you could implement a <a href="qhash.html#qHashx">qHash</a>() overload for std::vector&lt;int&gt;:</p>
<pre class="cpp">

  <span class="keyword">inline</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <a href="qhash.html#qHashx">qHash</a>(<span class="keyword">const</span> std<span class="operator">::</span>vector<span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> <span class="operator">&amp;</span>key<span class="operator">,</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> seed <span class="operator">=</span> <span class="number">0</span>)
  {
      <span class="keyword">return</span> qHashRange(key<span class="operator">.</span>begin()<span class="operator">,</span> key<span class="operator">.</span>end()<span class="operator">,</span> seed);
  }

</pre>
<p>It bears repeating that the implementation of qHashRange() - like the <a href="qhash.html#qHashx">qHash</a>() overloads offered by Qt - may change at any time. You <b>must not</b> rely on the fact that qHashRange() will give the same results (for the same inputs) across different Qt versions, even if <a href="qhash.html#qHashx">qHash</a>() for the element type would.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qhash.html#qHashBits">qHashBits</a>() and <a href="qhash.html#qHashRangeCommutative">qHashRangeCommutative</a>().</p>
<!-- @@@qHashRange -->
<!-- $$$qHashRangeCommutative[overload1]$$$qHashRangeCommutativeInputIteratorInputIteratoruint -->
<h3 class="fn" id="qHashRangeCommutative"><a name="qHashRangeCommutative"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHashRangeCommutative</span>(<span class="type">InputIterator</span> <i>first</i>, <span class="type">InputIterator</span> <i>last</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for the range [<i>first</i>,<i>last</i>), using <i>seed</i> to seed the calculation, by successively applying <a href="qhash.html#qHashx">qHash</a>() to each element and combining the hash values into a single one.</p>
<p>The return value of this function does not depend on the order of elements in the range. That means that</p>
<pre class="cpp">

  {<span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">2</span>}

</pre>
<p>and</p>
<pre class="cpp">

  {<span class="number">1</span><span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span>}

</pre>
<p>hash to the <b>same</b> values. If order matters, for example, for vectors and arrays, use <a href="qhash.html#qHashRange">qHashRange</a>() instead. If you are hashing raw memory, use <a href="qhash.html#qHashBits">qHashBits</a>().</p>
<p>Use this function only to implement <a href="qhash.html#qHashx">qHash</a>() for your own custom types. For example, here's how you could implement a <a href="qhash.html#qHashx">qHash</a>() overload for std::unordered_set&lt;int&gt;:</p>
<pre class="cpp">

  <span class="keyword">inline</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <a href="qhash.html#qHashx">qHash</a>(<span class="keyword">const</span> std<span class="operator">::</span>unordered_set<span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> <span class="operator">&amp;</span>key<span class="operator">,</span> <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> seed <span class="operator">=</span> <span class="number">0</span>)
  {
      <span class="keyword">return</span> qHashRangeCommutative(key<span class="operator">.</span>begin()<span class="operator">,</span> key<span class="operator">.</span>end()<span class="operator">,</span> seed);
  }

</pre>
<p>It bears repeating that the implementation of qHashRangeCommutative() - like the <a href="qhash.html#qHashx">qHash</a>() overloads offered by Qt - may change at any time. You <b>must not</b> rely on the fact that qHashRangeCommutative() will give the same results (for the same inputs) across different Qt versions, even if <a href="qhash.html#qHashx">qHash</a>() for the element type would.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qhash.html#qHashBits">qHashBits</a>() and <a href="qhash.html#qHashRange">qHashRange</a>().</p>
<!-- @@@qHashRangeCommutative -->
<!-- $$$qSetGlobalQHashSeed[overload1]$$$qSetGlobalQHashSeedint -->
<h3 class="fn" id="qSetGlobalQHashSeed"><a name="qSetGlobalQHashSeed"></a><span class="type">void</span> <span class="name">qSetGlobalQHashSeed</span>(<span class="type">int</span> <i>newSeed</i>)</h3>
<p>Sets the global <a href="qhash.html#qhash">QHash</a> seed to <i>newSeed</i>.</p>
<p>Manually setting the global <a href="qhash.html#qhash">QHash</a> seed value should be done only for testing and debugging purposes, when deterministic and reproducible behavior on a <a href="qhash.html#qhash">QHash</a> is needed. We discourage to do it in production code as it can make your application susceptible to <a href="qhash.html#algorithmic-complexity-attacks">algorithmic complexity attacks</a>.</p>
<p>The seed is set in any newly created <a href="qhash.html#qhash">QHash</a>. See <a href="qhash.html#qhash">qHash</a> about how this seed is being used by <a href="qhash.html#qhash">QHash</a>.</p>
<p>If the environment variable <code>QT_HASH_SEED</code> is set, calling this function will result in a no-op.</p>
<p>Passing the value -1 will reinitialize the global <a href="qhash.html#qhash">QHash</a> seed to a random value.</p>
<p>This function was introduced in  Qt 5.6.</p>
<p><b>See also </b><a href="qhash.html#qGlobalQHashSeed">qGlobalQHashSeed</a>.</p>
<!-- @@@qSetGlobalQHashSeed -->
<!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQHash<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="qhash.html#QHash">QHash</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>hash</i>)</h3>
<p>Writes the hash <i>hash</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">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QHash<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="qhash.html#QHash">QHash</a></span>&lt;<span class="type">Key</span>, <span class="type">T</span>&gt; &amp;<i>hash</i>)</h3>
<p>Reads a hash from stream <i>in</i> into <i>hash</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">Serializing Qt Data Types</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>