Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QHash< Key, T > Class Template Reference

\inmodule QtCore More...

#include <qhash.h>

+ Collaboration diagram for QHash< Key, T >:

Classes

class  const_iterator
 \inmodule QtCore More...
 
class  iterator
 \inmodule QtCore More...
 
class  key_iterator
 \inmodule QtCore More...
 

Public Types

using key_type = Key
 Typedef for Key.
 
using mapped_type = T
 Typedef for T.
 
using value_type = T
 
using size_type = qsizetype
 Typedef for int.
 
using difference_type = qsizetype
 Typedef for ptrdiff_t.
 
using reference = T &
 
using const_reference = const T &
 
typedef QKeyValueIterator< const Key &, const T &, const_iteratorconst_key_value_iterator
 \inmodule QtCore
 
typedef QKeyValueIterator< const Key &, T &, iteratorkey_value_iterator
 \inmodule QtCore
 
typedef iterator Iterator
 Qt-style synonym for QHash::iterator.
 
typedef const_iterator ConstIterator
 Qt-style synonym for QHash::const_iterator.
 

Public Member Functions

 QHash () noexcept=default
 Constructs an empty hash.
 
 QHash (std::initializer_list< std::pair< Key, T > > list)
 
 QHash (const QHash &other) noexcept
 Constructs a copy of other.
 
 ~QHash ()
 Destroys the hash.
 
QHashoperator= (const QHash &other) noexcept(std::is_nothrow_destructible< Node >::value)
 Assigns other to this hash and returns a reference to this hash.
 
 QHash (QHash &&other) noexcept
 Move-constructs a QHash instance, making it point at the same object that other was pointing to.
 
template<typename InputIterator , QtPrivate::IfAssociativeIteratorHasKeyAndValue< InputIterator > = true>
 QHash (InputIterator f, InputIterator l)
 
template<typename InputIterator , QtPrivate::IfAssociativeIteratorHasFirstAndSecond< InputIterator > = true>
 QHash (InputIterator f, InputIterator l)
 
void swap (QHash &other) noexcept
 
template<typename AKey = Key, typename AT = T>
QTypeTraits::compare_eq_result_container< QHash, AKey, AToperator== (const QHash &other) const noexcept
 Returns true if other is equal to this hash; otherwise returns false.
 
template<typename AKey = Key, typename AT = T>
QTypeTraits::compare_eq_result_container< QHash, AKey, AToperator!= (const QHash &other) const noexcept
 Returns true if other is not equal to this hash; otherwise returns false.
 
qsizetype size () const noexcept
 Returns the number of items in the hash.
 
bool isEmpty () const noexcept
 Returns true if the hash contains no items; otherwise returns false.
 
qsizetype capacity () const noexcept
 Returns the number of buckets in the QHash's internal hash table.
 
void reserve (qsizetype size)
 Ensures that the QHash's internal hash table has space to store at least size items without having to grow the hash table.
 
void squeeze ()
 Reduces the size of the QHash's internal hash table to save memory.
 
void detach ()
 
bool isDetached () const noexcept
 
bool isSharedWith (const QHash &other) const noexcept
 
void clear () noexcept(std::is_nothrow_destructible< Node >::value)
 Removes all items from the hash and frees up all memory used by it.
 
bool remove (const Key &key)
 Removes the item that has the key from the hash.
 
template<typename Predicate >
qsizetype removeIf (Predicate pred)
 
take (const Key &key)
 Removes the item with the key from the hash and returns the value associated with it.
 
bool contains (const Key &key) const noexcept
 Returns true if the hash contains an item with the key; otherwise returns false.
 
qsizetype count (const Key &key) const noexcept
 Returns the number of items associated with the key.
 
Key key (const T &value) const noexcept
 
Key key (const T &value, const Key &defaultKey) const noexcept
 
value (const Key &key) const noexcept
 
value (const Key &key, const T &defaultValue) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the value associated with the key.
 
T & operator[] (const Key &key)
 Returns the value associated with the key as a modifiable reference.
 
const T operator[] (const Key &key) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as value().
 
QList< Keykeys () const
 Returns a list containing all the keys in the hash, in an arbitrary order.
 
QList< Keykeys (const T &value) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a list containing all the keys associated with value value, in an arbitrary order.
 
QList< T > values () const
 Returns a list containing all the values in the hash, in an arbitrary order.
 
iterator begin ()
 Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
 
const_iterator begin () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator cbegin () const noexcept
 
const_iterator constBegin () const noexcept
 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
 
iterator end () noexcept
 Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the hash.
 
const_iterator end () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator cend () const noexcept
 
const_iterator constEnd () const noexcept
 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the hash.
 
key_iterator keyBegin () const noexcept
 
key_iterator keyEnd () const noexcept
 
key_value_iterator keyValueBegin ()
 
key_value_iterator keyValueEnd ()
 
const_key_value_iterator keyValueBegin () const noexcept
 
const_key_value_iterator constKeyValueBegin () const noexcept
 
const_key_value_iterator keyValueEnd () const noexcept
 
const_key_value_iterator constKeyValueEnd () const noexcept
 
auto asKeyValueRange () &
 
auto asKeyValueRange () const &
 
auto asKeyValueRange () &&
 
auto asKeyValueRange () const &&
 
iterator erase (const_iterator it)
 
QPair< iterator, iteratorequal_range (const Key &key)
 
QPair< const_iterator, const_iteratorequal_range (const Key &key) const noexcept
 
qsizetype count () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as size().
 
iterator find (const Key &key)
 Returns an iterator pointing to the item with the key in the hash.
 
const_iterator find (const Key &key) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator constFind (const Key &key) const noexcept
 
iterator insert (const Key &key, const T &value)
 Inserts a new item with the key and a value of value.
 
void insert (const QHash &hash)
 
template<typename ... Args>
iterator emplace (const Key &key, Args &&... args)
 
template<typename ... Args>
iterator emplace (Key &&key, Args &&... args)
 Inserts a new element into the container.
 
float load_factor () const noexcept
 Returns the current load factor of the QHash's internal hash table.
 
size_t bucket_count () const noexcept
 
bool empty () const noexcept
 This function is provided for STL compatibility.
 

Static Public Member Functions

static float max_load_factor () noexcept
 
static size_t max_bucket_count () noexcept
 

Friends

class QSet< Key >
 
class QMultiHash< Key, T >
 
class iterator
 
class const_iterator
 

Related Symbols

(Note that these are not member symbols.)

size_t qHash (const QUrl &url, size_t seed) noexcept
 Returns the hash value for the url.
 
size_t qHash (const QDateTime &key, size_t seed=0)
 
size_t qHash (QDate key, size_t seed=0)
 
size_t qHash (QTime key, size_t seed=0)
 
template< typename T1, typename T2 > size_t qHash (const std::pair< T1, T2 > &key, size_t seed=0)
 
template< typename... T > size_t qHashMulti (size_t seed, const T &...args)
 
template< typename... T > size_t qHashMultiCommutative (size_t seed, const T &...args)
 
template< typename InputIterator > size_t qHashRange (InputIterator first, InputIterator last, size_t seed=0)
 
template< typename InputIterator > size_t qHashRangeCommutative (InputIterator first, InputIterator last, size_t seed=0)
 
size_t qHashBits (const void *p, size_t len, size_t seed=0)
 
size_t qHash (char key, size_t seed=0)
 
size_t qHash (uchar key, size_t seed=0)
 
size_t qHash (signed char key, size_t seed=0)
 
size_t qHash (ushort key, size_t seed=0)
 
size_t qHash (short key, size_t seed=0)
 
size_t qHash (uint key, size_t seed=0)
 
size_t qHash (int key, size_t seed=0)
 
size_t qHash (ulong key, size_t seed=0)
 
size_t qHash (long key, size_t seed=0)
 
size_t qHash (quint64 key, size_t seed=0)
 
size_t qHash (qint64 key, size_t seed=0)
 
size_t qHash (char8_t key, size_t seed=0)
 
size_t qHash (char16_t key, size_t seed=0)
 
size_t qHash (char32_t key, size_t seed=0)
 
size_t qHash (wchar_t key, size_t seed=0)
 
size_t qHash (float key, size_t seed=0) noexcept
 
size_t qHash (double key, size_t seed) noexcept
 
size_t qHash (long double key, size_t seed) noexcept
 
size_t qHash (const QChar key, size_t seed=0)
 
size_t qHash (const QByteArray &key, size_t seed=0)
 
size_t qHash (const QByteArrayView &key, size_t seed=0)
 
size_t qHash (const QBitArray &key, size_t seed=0)
 
size_t qHash (const QString &key, size_t seed=0)
 
size_t qHash (QLatin1StringView key, size_t seed=0)
 
template< class T > size_t qHash (const T *key, size_t seed=0)
 
template< class T > size_t qHash (std::nullptr_t key, size_t seed=0)
 
template< typename T > bool qHashEquals (const T &a, const T &b)
 
template< class Key, class T > QDataStreamoperator<< (QDataStream &out, const QHash< Key, T > &hash)
 Writes the hash hash to stream out.
 
template< class Key, class T > QDataStreamoperator>> (QDataStream &in, QHash< Key, T > &hash)
 Reads a hash from stream in into hash.
 
template< class Key, class T > size_t qHash (const QHash< Key, T > &key, size_t seed=0)
 
template< typename Key, typename T, typename Predicate > qsizetype erase_if (QHash< Key, T > &hash, Predicate pred)
 
size_t qHash (QPoint key, size_t seed=0)
 
size_t qHash (const QVersionNumber &key, size_t seed)
 
size_t qHash (const QTypeRevision &key, size_t seed)
 
size_t qHash (const QOcspResponse &response, size_t seed) noexcept
 Returns the hash value for the response, using seed to seed the calculation.
 
size_t qHash (const QSslCertificate &key, size_t seed) noexcept
 Returns the hash value for the key, using seed to seed the calculation.
 
size_t qHash (QSslEllipticCurve curve, size_t seed=0)
 
size_t qHash (const QSslError &key, size_t seed) noexcept
 Returns the hash value for the key, using seed to seed the calculation.
 
size_t qHash (const QGeoCoordinate &coordinate, size_t seed=0)
 Returns a hash value for coordinate, using seed to seed the calculation.
 

Detailed Description

template<typename Key, typename T>
class QHash< Key, T >

\inmodule QtCore

The QHash class is a template class that provides a hash-table-based dictionary.

\reentrant

QHash<Key, T> is one of Qt's generic \l{container classes}. It stores (key, value) pairs and provides very fast lookup of the value associated with a key.

QHash provides very similar functionality to QMap. The differences are:

\list

  • QHash provides faster lookups than QMap. (See \l{Algorithmic Complexity} for details.)
  • When iterating over a QMap, the items are always sorted by key. With QHash, the items are arbitrarily ordered.
  • The key type of a QMap must provide operator<(). The key type of a QHash must provide operator==() and a global hash function called qHash() (see \l{qHash}). \endlist

Here's an example QHash with QString keys and int values:

\inmodule QtCore
Definition qhash.h:818
QHash< int, QWidget * > hash
[35multi]

To insert a (key, value) pair into the hash, you can use operator[]():

hash["one"] = 1;
hash["three"] = 3;
hash["seven"] = 7;

This inserts the following three (key, value) pairs into the QHash: ("one", 1), ("three", 3), and ("seven", 7). Another way to insert items into the hash is to use insert():

hash.insert("twelve", 12);

To look up a value, use operator[]() or value():

int num1 = hash["thirteen"];
int num2 = hash.value("thirteen");

If there is no item with the specified key in the hash, these functions return a \l{default-constructed value}.

If you want to check whether the hash contains a particular key, use contains():

int timeout = 30;
if (hash.contains("TIMEOUT"))
timeout = hash.value("TIMEOUT");
GLbitfield GLuint64 timeout
[4]

There is also a value() overload that uses its second argument as a default value if there is no item with the specified key:

int timeout = hash.value("TIMEOUT", 30);

In general, we recommend that you use contains() and value() 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:

// WRONG
...
for (int i = 0; i < 1000; ++i) {
if (hash[i] == okButton)
cout << "Found button at index " << i << endl;
}

To avoid this problem, replace hash[i] with hash.value(i) in the code above.

Internally, QHash uses a hash table to perform lookups. This hash table automatically grows to provide fast lookups without wasting too much memory. You can still control the size of the hash table by calling reserve() if you already know approximately how many items the QHash will contain, but this isn't necessary to obtain good performance. You can also call capacity() to retrieve the hash table's size.

QHash will not shrink automatically if items are removed from the table. To minimize the memory used by the hash, call squeeze().

If you want to navigate through all the (key, value) pairs stored in a QHash, you can use an iterator. QHash provides both \l{Java-style iterators} (QHashIterator and QMutableHashIterator) and \l{STL-style iterators} (QHash::const_iterator and QHash::iterator). Here's how to iterate over a QHash<QString, int> using a Java-style iterator:

QHashIterator<QString, int> i(hash);
while (i.hasNext()) {
i.next();
cout << qPrintable(i.key()) << ": " << i.value() << endl;
}
#define qPrintable(string)
Definition qstring.h:1391

Here's the same code, but using an STL-style iterator:

for (auto i = hash.cbegin(), end = hash.cend(); i != end; ++i)
cout << qPrintable(i.key()) << ": " << i.value() << endl;
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
Definition qhash.h:1206
GLuint GLuint end

QHash is unordered, so an iterator's sequence cannot be assumed to be predictable. If ordering by key is required, use a QMap.

A QHash allows only one value per key. If you call insert() with a key that already exists in the QHash, the previous value is erased. For example:

hash.insert("plenty", 100);
hash.insert("plenty", 2000);
// hash.value("plenty") == 2000

If you need to store multiple entries for the same key in the hash table, use \l{QMultiHash}.

If you only need to extract the values from a hash (not the keys), you can also use range-based for:

...
for (int value : std::as_const(hash))
cout << value << endl;
EGLOutputLayerEXT EGLint EGLAttrib value
[5]

Items can be removed from the hash in several ways. One way is to call remove(); this will remove any item with the given key. Another way is to use QMutableHashIterator::remove(). In addition, you can clear the entire hash using clear().

QHash's key and value data types must be \l{assignable data types}. You cannot, for example, store a QWidget as a value; instead, store a QWidget *.

\target qHash

Definition at line 817 of file qhash.h.

Member Typedef Documentation

◆ const_key_value_iterator

template<typename Key , typename T >
QHash< Key, T >::const_key_value_iterator

\inmodule QtCore

Since
5.10

The QHash::const_key_value_iterator typedef provides an STL-style const iterator for QHash.

QHash::const_key_value_iterator is essentially the same as QHash::const_iterator with the difference that operator*() returns a key/value pair instead of a value.

See also
QKeyValueIterator

Definition at line 1198 of file qhash.h.

◆ const_reference

template<typename Key , typename T >
using QHash< Key, T >::const_reference = const T &

Definition at line 834 of file qhash.h.

◆ ConstIterator

template<typename Key , typename T >
QHash< Key, T >::ConstIterator

Qt-style synonym for QHash::const_iterator.

Definition at line 1256 of file qhash.h.

◆ difference_type

template<typename Key , typename T >
QHash< Key, T >::difference_type

Typedef for ptrdiff_t.

Provided for STL compatibility.

Definition at line 832 of file qhash.h.

◆ Iterator

template<typename Key , typename T >
QHash< Key, T >::Iterator

Qt-style synonym for QHash::iterator.

Definition at line 1255 of file qhash.h.

◆ key_type

template<typename Key , typename T >
QHash< Key, T >::key_type

Typedef for Key.

Provided for STL compatibility.

Definition at line 828 of file qhash.h.

◆ key_value_iterator

template<typename Key , typename T >
QHash< Key, T >::key_value_iterator

\inmodule QtCore

Since
5.10

The QHash::key_value_iterator typedef provides an STL-style iterator for QHash.

QHash::key_value_iterator is essentially the same as QHash::iterator with the difference that operator*() returns a key/value pair instead of a value.

See also
QKeyValueIterator

Definition at line 1199 of file qhash.h.

◆ mapped_type

template<typename Key , typename T >
QHash< Key, T >::mapped_type

Typedef for T.

Provided for STL compatibility.

Definition at line 829 of file qhash.h.

◆ reference

template<typename Key , typename T >
using QHash< Key, T >::reference = T &

Definition at line 833 of file qhash.h.

◆ size_type

template<typename Key , typename T >
QHash< Key, T >::size_type

Typedef for int.

Provided for STL compatibility.

Definition at line 831 of file qhash.h.

◆ value_type

template<typename Key , typename T >
using QHash< Key, T >::value_type = T

Definition at line 830 of file qhash.h.

Constructor & Destructor Documentation

◆ QHash() [1/6]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::QHash ( )
inlinedefaultnoexcept

Constructs an empty hash.

See also
clear()

Referenced by QHash< Key, T >::operator[]().

+ Here is the caller graph for this function:

◆ QHash() [2/6]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::QHash ( std::initializer_list< std::pair< Key, T > >  list)
inline
Since
5.1

Constructs a hash with a copy of each of the elements in the initializer list list.

Definition at line 837 of file qhash.h.

References QList< T >::begin(), QList< T >::end(), QHash< Key, T >::insert(), it, and list.

+ Here is the call graph for this function:

◆ QHash() [3/6]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::QHash ( const QHash< Key, T > &  other)
inlinenoexcept

Constructs a copy of other.

This operation occurs in \l{constant time}, because QHash is \l{implicitly shared}. This makes returning a QHash from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and this takes \l{linear time}.

See also
operator=()

Definition at line 843 of file qhash.h.

References d.

◆ ~QHash()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::~QHash ( )
inline

Destroys the hash.

References to the values in the hash and all iterators of this hash become invalid.

Definition at line 849 of file qhash.h.

References d.

◆ QHash() [4/6]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::QHash ( QHash< Key, T > &&  other)
inlinenoexcept

Move-constructs a QHash instance, making it point at the same object that other was pointing to.

Since
5.2

Definition at line 871 of file qhash.h.

◆ QHash() [5/6]

template<typename Key , typename T >
template<typename InputIterator , QtPrivate::IfAssociativeIteratorHasKeyAndValue< InputIterator > = true>
template< class Key, class T > template< class InputIterator > QHash< Key, T >::QHash ( InputIterator  begin,
InputIterator  end 
)
inline
Since
5.14

Constructs a hash with a copy of each of the elements in the iterator range [begin, end). Either the elements iterated by the range must be objects with {first} and {second} data members (like {QPair}, {std::pair}, etc.) convertible to Key and to T respectively; or the iterators must have {key()} and {value()} member functions, returning a key convertible to Key and a value convertible to T respectively.

Definition at line 881 of file qhash.h.

References QHash< Key, T >::insert(), and QtPrivate::reserveIfForwardIterator().

+ Here is the call graph for this function:

◆ QHash() [6/6]

template<typename Key , typename T >
template<typename InputIterator , QtPrivate::IfAssociativeIteratorHasFirstAndSecond< InputIterator > = true>
QHash< Key, T >::QHash ( InputIterator  f,
InputIterator  l 
)
inline

Definition at line 890 of file qhash.h.

References QHash< Key, T >::insert(), and QtPrivate::reserveIfForwardIterator().

+ Here is the call graph for this function:

Member Function Documentation

◆ asKeyValueRange() [1/4]

template<typename Key , typename T >
auto QHash< Key, T >::asKeyValueRange ( ) &
inline

Definition at line 1218 of file qhash.h.

Referenced by ForbiddenChildrenPropertyValidatorPass::run(), ForbiddenChildrenPropertyValidatorPass::shouldRun(), and QmlTypeRegistrar::write().

+ Here is the caller graph for this function:

◆ asKeyValueRange() [2/4]

template<typename Key , typename T >
auto QHash< Key, T >::asKeyValueRange ( ) &&
inline

Definition at line 1220 of file qhash.h.

◆ asKeyValueRange() [3/4]

template<typename Key , typename T >
auto QHash< Key, T >::asKeyValueRange ( ) const &
inline

Definition at line 1219 of file qhash.h.

◆ asKeyValueRange() [4/4]

template<typename Key , typename T >
auto QHash< Key, T >::asKeyValueRange ( ) const &&
inline

Definition at line 1221 of file qhash.h.

◆ begin() [1/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::iterator QHash< Key, T >::begin ( )
inline

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.

See also
constBegin(), end()

Definition at line 1202 of file qhash.h.

References d, and QHash< Key, T >::detach().

Referenced by QQuickDesignerSupport::~QQuickDesignerSupport(), QQuickSmoothedAnimationPrivate::~QQuickSmoothedAnimationPrivate(), QQuickTimeLine::~QQuickTimeLine(), QSmoothedAnimation::~QSmoothedAnimation(), QSpringAnimation::~QSpringAnimation(), QWindowsDirectWriteFontDatabase::~QWindowsDirectWriteFontDatabase(), QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(), QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QQuickTimeLinePrivate::advance(), QSet< T >::begin(), QV4::MultiplyWrappedQObjectMap::begin(), QSet< T >::begin(), QV4DebuggerAgent::breakPointIds(), QGraphicsScenePrivate::cancelGesturesForChildren(), QSet< T >::cbegin(), QSqlDatabasePrivate::cleanConnections(), QWaylandTextureSharingExtension::cleanupBuffers(), QSSGRhiContext::cleanupDrawCallData(), QNetworkAccessCache::clear(), QQmlTypeLoader::clearCache(), QQmlJS::Dom::AstComments::collectComments(), QHash< Key, T >::constKeyValueBegin(), QD3D11Buffer::destroy(), QRhiGles2::dispatch(), QRhiVulkan::dispatch(), QGraphicsScenePrivate::gestureEventHandler(), QSGRhiAtlasTexture::Manager::invalidate(), QSGDefaultRenderContext::invalidateGlyphCaches(), QSimplexConstraint::invert(), QHash< Key, T >::keyBegin(), QHash< Key, T >::keys(), QHash< Key, T >::keyValueBegin(), QHash< Key, T >::keyValueBegin(), QWindowsCursor::pixmapWindowCursor(), QTextureGlyphCache::populate(), QSGDefaultRenderContext::preprocess(), qt_debug_print_texture_count(), QSvgIconEngine::read(), readDependencies(), QGraphicsScenePrivate::removeItemHelper(), QAndroidPlatformMenuBar::removeMenu(), QAndroidPlatformMenu::removeMenuItem(), QQuickWorkerScriptEngine::run(), AnchorsValidatorPass::run(), QSocks5BindStore::timerEvent(), QQmlTypeLoader::trimCache(), QQuickSpringAnimationPrivate::updateMode(), QQuickItemViewPrivate::updateUnrequestedIndexes(), VDMAbstractItemModelDataType::value(), and QHash< Key, T >::values().

+ Here is the call graph for this function:

◆ begin() [2/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_iterator QHash< Key, T >::begin ( ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1203 of file qhash.h.

References d.

◆ bucket_count()

template<typename Key , typename T >
size_t QHash< Key, T >::bucket_count ( ) const
inlinenoexcept

Definition at line 1326 of file qhash.h.

References d.

◆ capacity()

template<typename Key , typename T >
template< class Key, class T > qsizetype QHash< Key, T >::capacity ( ) const
inlinenoexcept

Returns the number of buckets in the QHash's internal hash table.

The sole purpose of this function is to provide a means of fine tuning QHash'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 size().

See also
reserve(), squeeze()

Definition at line 928 of file qhash.h.

References d.

Referenced by QSet< T >::capacity(), QHash< Key, T >::reserve(), and QHash< Key, T >::squeeze().

+ Here is the caller graph for this function:

◆ cbegin()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_iterator QHash< Key, T >::cbegin ( ) const
inlinenoexcept
Since
5.0

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.

See also
begin(), cend()

Definition at line 1204 of file qhash.h.

References d.

Referenced by QGestureManager::~QGestureManager(), QItemEditorFactory::~QItemEditorFactory(), QRhiImplementation::~QRhiImplementation(), QtFreetypeData::~QtFreetypeData(), QQuickTimeLine::clear(), QWindowsContext::findPlatformWindow(), QCocoaTouch::getCurrentTouchPointList(), QDBusSnippets::operator<<(), QItemEditorFactory::registerEditor(), QGeoTiledMapScene::updateSceneGraph(), QQuickItemViewPrivate::updateUnrequestedPositions(), and QSvgIconEngine::write().

+ Here is the caller graph for this function:

◆ cend()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_iterator QHash< Key, T >::cend ( ) const
inlinenoexcept
Since
5.0

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the hash.

See also
cbegin(), end()

Definition at line 1208 of file qhash.h.

Referenced by QGestureManager::~QGestureManager(), QItemEditorFactory::~QItemEditorFactory(), QRhiImplementation::~QRhiImplementation(), QtFreetypeData::~QtFreetypeData(), QNetworkReplyHttpImplPrivate::_q_metaDataChanged(), QWidgetAnimator::abort(), Graph< Vertex, EdgeData >::adjacentVertices(), QCommandLineParserPrivate::aliases(), QSSGRhiShaderPipeline::bindingForTexture(), QQuickTimeLine::clear(), QSGRhiAtlasTexture::Manager::create(), Graph< Vertex, EdgeData >::edgeData(), QWindowsContext::findPlatformWindow(), QSSGLayerRenderData::getBonemapTexture(), QSSGShaderLibraryManager::getIncludeContents(), QSSGLayerRenderData::getLightmapTexture(), QSSGShaderLibraryManager::getShaderMetaData(), QSSGShaderLibraryManager::getShaderSource(), QFontEngine::glyphCache(), QAndroidActivityResultReceiverPrivate::handleActivityResult(), importImp(), QNetworkReplyImplPrivate::metaDataChanged(), QPMCache::object(), QSSGRhiShaderPipeline::offsetOfUniform(), QDBusSnippets::operator<<(), QItemEditorFactory::registerEditor(), QAbstractItemViewPrivate::removeEditor(), QSocks5BindStore::retrieve(), QSSGRhiShaderPipeline::setUniform(), QSSGRhiShaderPipeline::setUniformArray(), QQmlOpenMetaObject::setValue(), QSSGShaderCache::tryGetRhiShaderPipeline(), QGeoTiledMapScene::updateSceneGraph(), QQuickItemViewPrivate::updateUnrequestedPositions(), QQmlOpenMetaObject::value(), QQmlOpenMetaObject::valueRef(), QCommandLineParser::values(), and QSvgIconEngine::write().

+ Here is the caller graph for this function:

◆ clear()

template<typename Key , typename T >
template< class Key, class T > void QHash< Key, T >::clear ( )
inlinenoexcept

Removes all items from the hash and frees up all memory used by it.

See also
remove()

Definition at line 949 of file qhash.h.

References d.

Referenced by QAndroidStyle::QAndroidStyle(), LinuxDmabufClientBufferIntegration::~LinuxDmabufClientBufferIntegration(), QApplication::~QApplication(), QOpenGLContextVersionData::~QOpenGLContextVersionData(), QQmlMetaTypeData::~QQmlMetaTypeData(), QQuickCanvasItemPrivate::~QQuickCanvasItemPrivate(), QQuickPixmapReader::~QQuickPixmapReader(), QtFreetypeData::~QtFreetypeData(), QHeaderViewPrivate::_q_sectionsChanged(), QSqlDatabasePrivate::cleanConnections(), QOpenGLContextGroupPrivate::cleanup(), QMimeAllGlobPatterns::clear(), QMimeTypePrivate::clear(), QSet< T >::clear(), QFontCache::clear(), QNetworkAccessCache::clear(), QHeaderViewPrivate::clear(), QQuickParticleDataHeap::clear(), QQuickTimeLine::clear(), QQmlTypeLoader::clearCache(), QQmlJSImporter::clearCache(), QHeaderViewPrivate::clearCascadingSections(), QRelation::clearDictionary(), QFont::clearFeatures(), QQuickTextDocumentWithImageResources::clearResources(), QRhiGles2::compileShader(), convertIterableToVariantHash(), QD3D11Buffer::destroy(), QRhiGles2::destroy(), QRhiMetal::destroy(), QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations(), QLowEnergyControllerPrivateBluezDBus::discoverServiceDetails(), QQmlTypeData::done(), QMimeXMLProvider::ensureLoaded(), QNetworkReplyHttpImplPrivate::followRedirect(), QGraphicsScenePrivate::gestureEventHandler(), QCocoaTouch::getCurrentTouchPointList(), QApplicationPrivate::handlePaletteChanged(), QQmlJSTypeResolver::init(), QHighDpiScaling::initHighDpiScaling(), QApplicationPrivate::initializeWidgetFontHash(), QApplicationPrivate::initializeWidgetPalettesFromTheme(), QSGRhiAtlasTexture::Manager::invalidate(), QCoreTextFontDatabase::invalidate(), QSGSoftwareRenderContext::invalidate(), QSGDefaultRenderContext::invalidate(), QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson(), QPpdPrintDevice::loadPageSizes(), QCocoaPrintDevice::loadPageSizes(), QDBusSnippets::operator>>(), QCommandLineParserPrivate::parse(), QCoreTextFontDatabase::populateFontDatabase(), QSvgIconEngine::read(), QSSGShaderCache::releaseCachedResources(), QSSGRhiContext::releaseCachedResources(), QSSGCustomMaterialSystem::releaseCachedResources(), QRhiGles2::releaseCachedResources(), QRhiMetal::releaseCachedResources(), QSGBatchRenderer::Renderer::releaseCachedResources(), QQuickTableViewPrivate::releaseLoadedItems(), QCFSocketNotifier::removeSocketNotifiers(), QBackingStoreRhiSupport::reset(), QGles2CommandBuffer::ComputePassState::reset(), QCocoaTheme::reset(), QFontLoaderFonts::reset(), QSGRhiShaderLinker::reset(), QSSGLayerRenderData::resetForFrame(), QDBusConnectionManager::run(), QQuickWorkerScriptEngine::run(), QQuickImageParticle::sceneGraphInvalidated(), QNetworkHeadersPrivate::setAllRawHeaders(), QQmlJSImporter::setImportPaths(), QIconLoader::setThemeSearchPath(), QQmlSettingsPrivate::store(), QWindowsMouseHandler::translateTouchEvent(), QSGDistanceFieldGlyphNode::updateGeometry(), QQuickImageParticle::updatePaintNode(), and QQuickAnimatorController::windowNodesDestroyed().

◆ constBegin()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_iterator QHash< Key, T >::constBegin ( ) const
inlinenoexcept

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.

See also
begin(), constEnd()

Definition at line 1205 of file qhash.h.

References d.

Referenced by QAndroidStyle::QAndroidStyle(), QCocoaCursor::~QCocoaCursor(), QQuickWanderAffector::~QQuickWanderAffector(), QMimeXMLProvider::addAllMimeTypes(), QGraphicsScenePrivate::addView(), QQuickTimeLinePrivate::advance(), QV4::MultiplyWrappedQObjectMap::begin(), QMetaStringTable::blobSize(), buildAndroidProject(), QOpenGLContextGroupPrivate::cleanup(), QQmlTypeCompiler::compile(), QSet< T >::constBegin(), QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations(), QQmlJSScope::enumerations(), QEvdevTouchScreenData::findClosestContact(), QMacPrintEnginePrivate::initialize(), VDMAbstractItemModelDataType::initializeConstructor(), QSGDefaultRenderContext::invalidate(), QSimplexConstraint::isSatisfied(), main(), QAndroidPlatformMenuBar::menuId(), QAndroidPlatformMenu::menuId(), QFont::operator<(), QQmlJSScope::properties(), pullFiles(), readInputFile(), readInputFileDirectory(), QGeoTiledMappingManagerEngine::releaseMap(), ThreadedTestHTTPServer::run(), QV4::MemoryManager::runGC(), QXcbConnection::startSystemMoveResizeForTouch(), QQmlSettingsPrivate::store(), QGraphicsScenePrivate::touchEventHandler(), QApplicationPrivate::translateRawTouchEvent(), QAbstractItemViewPrivate::updateEditorData(), updateFile(), QSGDistanceFieldGlyphNode::updateGeometry(), updateLibsXml(), QSGRhiShaderEffectMaterial::updateTextureProviders(), QMetaStringTable::writeBlob(), QQmlToolingSettings::writeDefaults(), and LinuxDmabuf::zwp_linux_dmabuf_v1_bind_resource().

+ Here is the caller graph for this function:

◆ constEnd()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_iterator QHash< Key, T >::constEnd ( ) const
inlinenoexcept

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the hash.

See also
constBegin(), end()

Definition at line 1209 of file qhash.h.

Referenced by QAndroidStyle::QAndroidStyle(), QCocoaCursor::~QCocoaCursor(), QQuickWanderAffector::~QQuickWanderAffector(), QMimeXMLProvider::addAllMimeTypes(), QGraphicsScenePrivate::addView(), QQuickTimeLinePrivate::advance(), QWidgetAnimator::animate(), QMetaStringTable::blobSize(), buildAndroidProject(), QQmlPropertyCache::checksum(), QOpenGLContextGroupPrivate::cleanup(), QQmlTypeCompiler::compile(), QRhiGles2::compileShader(), QSSGRhiContext::computePipeline(), QSet< T >::constEnd(), QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations(), QSSGRhiContext::dummyTexture(), QQmlOpenMetaObject::emitPropertyNotification(), QV4::MultiplyWrappedQObjectMap::end(), QQmlJSScope::enumerations(), QHash< Key, T >::erase(), fileArchitecture(), QEvdevTouchScreenData::findClosestContact(), QQmlMetaTypeData::findPropertyCacheInCompositeTypes(), StaticUnitCache::get(), getQtLibsFromElf(), QQmlDebugServerImpl::hasEngine(), QWindowsCursor::hCursor(), QMacPrintEnginePrivate::initialize(), VDMAbstractItemModelDataType::initializeConstructor(), QSGDefaultRenderContext::invalidate(), QSimplexConstraint::isSatisfied(), QQmlPreviewFileLoader::load(), Cache::lookup(), main(), QAndroidPlatformMenuBar::menuId(), QAndroidPlatformMenu::menuId(), QDesktopServices::openUrl(), QFont::operator<(), QCommandLineParserPrivate::parse(), QCommandLineParserPrivate::parseOptionValue(), QSSGRhiContext::pipeline(), processNode(), QQmlJSScope::properties(), QQuickShaderEffectPrivate::propertyChanged(), qCompileQmlFile(), readInputFile(), readInputFileDirectory(), QQmlMetaTypeData::registerModuleTypes(), QFreetypeFace::release(), QGeoTiledMappingManagerEngine::releaseMap(), QXcbEventQueue::removePeekerId(), QQmlProfilerClientPrivate::resolveType(), QtWaylandClient::QWaylandMimeData::retrieveData_sys(), ThreadedTestHTTPServer::run(), QV4::MemoryManager::runGC(), QSSGRhiShaderPipeline::setUniform(), QSSGRhiShaderPipeline::setUniformArray(), QSSGRhiContext::srb(), QQmlJSCodeGenerator::startInstruction(), QXcbConnection::startSystemMoveResizeForTouch(), QQmlSettingsPrivate::store(), QFont::substitute(), QBackingStoreRhiSupport::swapChainForWindow(), QGraphicsScenePrivate::touchEventHandler(), QApplicationPrivate::translateRawTouchEvent(), QAbstractItemViewPrivate::updateEditorData(), updateFile(), QSGDistanceFieldGlyphNode::updateGeometry(), updateLibsXml(), QSGRhiShaderEffectMaterial::updateTextureProviders(), QMetaStringTable::writeBlob(), QQmlToolingSettings::writeDefaults(), and LinuxDmabuf::zwp_linux_dmabuf_v1_bind_resource().

◆ constFind()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_iterator QHash< Key, T >::constFind ( const Key key) const
inlinenoexcept
Since
4.1

Returns an iterator pointing to the item with the key in the hash.

If the hash contains no item with the key, the function returns constEnd().

See also
find()

Definition at line 1279 of file qhash.h.

References QHash< Key, T >::find().

Referenced by QNetworkReplyHttpImplPrivate::_q_metaDataChanged(), QWidgetAnimator::abort(), Graph< Vertex, EdgeData >::adjacentVertices(), QCommandLineParserPrivate::aliases(), QWidgetAnimator::animate(), QSSGRhiShaderPipeline::bindingForTexture(), QQmlPropertyCache::checksum(), QRhiGles2::compileShader(), QSSGRhiContext::computePipeline(), QSSGRhiContext::dummyTexture(), Graph< Vertex, EdgeData >::edgeData(), QQmlOpenMetaObject::emitPropertyNotification(), QQmlMetaTypeData::findPropertyCacheInCompositeTypes(), StaticUnitCache::get(), QSSGLayerRenderData::getBonemapTexture(), QSSGShaderLibraryManager::getIncludeContents(), QSSGLayerRenderData::getLightmapTexture(), QSSGShaderLibraryManager::getShaderMetaData(), QSSGShaderLibraryManager::getShaderSource(), QFontEngine::glyphCache(), QQmlDebugServerImpl::hasEngine(), QWindowsCursor::hCursor(), importImp(), QQmlPreviewFileLoader::load(), Cache::lookup(), QNetworkReplyImplPrivate::metaDataChanged(), QSSGRhiShaderPipeline::offsetOfUniform(), QDesktopServices::openUrl(), QCommandLineParserPrivate::parse(), QCommandLineParserPrivate::parseOptionValue(), QSSGRhiContext::pipeline(), processNode(), QQuickShaderEffectPrivate::propertyChanged(), qCompileQmlFile(), QItemEditorFactory::registerEditor(), QQmlMetaTypeData::registerModuleTypes(), QFreetypeFace::release(), QAbstractItemViewPrivate::removeEditor(), QXcbEventQueue::removePeekerId(), QQmlProfilerClientPrivate::resolveType(), QSocks5BindStore::retrieve(), QtWaylandClient::QWaylandMimeData::retrieveData_sys(), QSSGRhiShaderPipeline::setUniform(), QSSGRhiShaderPipeline::setUniformArray(), QQmlOpenMetaObject::setValue(), QQmlOpenMetaObject::setValues(), QSSGRhiContext::srb(), QQmlJSCodeGenerator::startInstruction(), QFont::substitute(), QBackingStoreRhiSupport::swapChainForWindow(), QSSGShaderCache::tryGetRhiShaderPipeline(), QQmlOpenMetaObject::value(), QQmlOpenMetaObject::valueRef(), and QCommandLineParser::values().

+ Here is the call graph for this function:

◆ constKeyValueBegin()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_key_value_iterator QHash< Key, T >::constKeyValueBegin ( ) const
inlinenoexcept
Since
5.10

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry in the hash.

See also
keyValueBegin()

Definition at line 1215 of file qhash.h.

References QHash< Key, T >::begin().

+ Here is the call graph for this function:

◆ constKeyValueEnd()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_key_value_iterator QHash< Key, T >::constKeyValueEnd ( ) const
inlinenoexcept
Since
5.10

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary entry after the last entry in the hash.

See also
constKeyValueBegin()

Definition at line 1217 of file qhash.h.

References QHash< Key, T >::end().

+ Here is the call graph for this function:

◆ contains()

template<typename Key , typename T >
template< class Key, class T > bool QHash< Key, T >::contains ( const Key key) const
inlinenoexcept

Returns true if the hash contains an item with the key; otherwise returns false.

See also
count(), QMultiHash::contains()

Definition at line 991 of file qhash.h.

References d.

Referenced by QSocks5BindStore::add(), QSqlDatabasePrivate::addDatabase(), QQmlDebugServerImpl::addEngine(), QSvgTinyDocument::addNamedStyle(), QCommandLineParser::addOption(), QQmlDebugServerImpl::addService(), QGeoTiledMapScenePrivate::addTile(), QGeoPositionInfo::attribute(), QGeoSatelliteInfo::attribute(), calculateKinematicNodeTransform(), QHeaderViewPrivate::cascadingResize(), QHaikuCursor::changeCursor(), Moc::checkSuperClasses(), QSet< T >::contains(), QSocks5BindStore::contains(), QColorOutputPrivate::containsColor(), QHash< Key, T >::count(), CustomDataProxy::data(), QGraphicsItem::data(), QQmlJSAnnotation::deprecation(), QLowEnergyControllerPrivateBluezDBus::discoverServiceDetails(), QQmlTableInstanceModel::dispose(), QSvgFont::draw(), QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QGestureManager::filterEvent(), QIcc::fromIccProfile(), QGraphicsScenePrivate::gestureEventHandler(), goodToCopy(), QSGSoftwareRenderLoop::grab(), QDialogButtonBoxPrivate::handleButtonShowAndHide(), QGeoPositionInfo::hasAttribute(), QGeoSatelliteInfo::hasAttribute(), QAbstractItemViewPrivate::hasEditor(), QNetworkAccessCache::hasEntry(), QQmlJSScope::hasEnumeration(), QQmlJSScope::hasProperty(), LinuxDmabufClientBufferIntegration::importBuffer(), importImp(), QDeclarativeSupportedCategoriesModel::index(), QQuickParticleDataHeap::insertTimed(), QQuickContext2DRenderThread::instance(), BluetoothManagement::isAddressRandom(), QQuickPixmap::isCached(), QFont::isFeatureSet(), QQmlJSScope::isIdInCurrentQmlScopes(), QQmlTypeLoader::isScriptLoaded(), QQmlToolingSettings::isSet(), QQmlTypeLoader::isTypeLoaded(), QQmlJS::Dom::MockObject::iterateDirectSubpaths(), QQmlJS::Dom::MockOwner::iterateDirectSubpaths(), QQmlJS::Dom::DomTop::iterateDirectSubpaths(), QWaylandIviApplicationPrivate::ivi_application_surface_create(), QSGRhiShaderLinker::linkTextureSubRects(), QQuickTableViewPrivate::loadedTableItem(), QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), loadTzTimeZones(), QCocoaPrintDevice::macPaper(), Preprocessor::macroExpandIdentifier(), Moc::parseClassHead(), parseServerList(), QSGOpenVGFontGlyphCache::populate(), QTextureGlyphCache::populate(), QPpdPrintDevice::printableMargins(), QCocoaPrintDevice::printableMargins(), QQuickShaderEffectPrivate::propertyChanged(), readInputFile(), readInputFileDirectory(), QQuickDesignerSupport::refFromEffectItem(), QCommandLineParserPrivate::registerFoundOption(), QCtfLibImpl::registerMetadata(), QQuickParticleSystem::registerParticleGroupData(), QEventDispatcherWin32::registerSocketNotifier(), QWaylandXdgOutputManagerV1Private::registerXdgOutput(), QQmlTableInstanceModel::release(), QSqlDatabasePrivate::removeDatabase(), QQmlDebugServerImpl::removeEngine(), QQmlWatcher::removeWatch(), QNetworkReplyHttpImplPrivate::replyDownloadMetaData(), QHeaderViewPrivate::saveCascadingSectionSize(), QQmlToolingSettings::search(), QQuickTableViewPrivate::selectionRectangle(), QHttp2ProtocolHandler::sendRequest(), QQuickTableViewPrivate::setCurrentIndexFromKeyEvent(), QQuickTableViewPrivate::setCurrentOnDelegateItem(), QQuickTableViewPrivate::setSelectedOnDelegateItem(), QV4::ExecutionEngine::stopTimer(), Preprocessor::substituteUntilNewline(), QtWaylandClient::QWaylandTextInputMethod::text_input_method_v1_end_input_method_event(), QtWaylandClient::QWaylandTextInputMethod::text_input_method_v1_input_method_event_attribute(), QtWaylandClient::QWaylandTextInputMethod::text_input_method_v1_start_input_method_event(), QWindowsMouseHandler::translateTouchEvent(), Driver::unique(), QQuickTableViewPrivate::unloadItem(), QSGSoftwareRenderableNodeUpdater::updateNodes(), QGeoTiledMapScene::updateSceneGraph(), QQmlJSImportVisitor::visit(), QTextOdfWriter::writeAll(), QTextOdfWriter::writeFrame(), QColorOutput::writePrefixedMessage(), QTextOdfWriter::writeTableCellFormat(), and QWaylandXdgOutputManagerV1Private::zxdg_output_manager_v1_get_xdg_output().

◆ count() [1/2]

template<typename Key , typename T >
template< class Key, class T > qsizetype QHash< Key, T >::count ( ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as size().

Definition at line 1257 of file qhash.h.

References d.

◆ count() [2/2]

template<typename Key , typename T >
template< class Key, class T > qsizetype QHash< Key, T >::count ( const Key key) const
inlinenoexcept

Returns the number of items associated with the key.

See also
contains()

Definition at line 997 of file qhash.h.

References QHash< Key, T >::contains().

+ Here is the call graph for this function:

◆ detach()

template<typename Key , typename T >
template< class Key, class T > void QHash< Key, T >::detach ( )
inline

Detaches this hash from any other hashes with which it may share data.

See also
isDetached()

Definition at line 945 of file qhash.h.

References d, and QHashPrivate::Data< Node >::detached().

Referenced by QHash< Key, T >::begin(), QSet< T >::detach(), QHash< Key, T >::emplace(), QHash< Key, T >::erase(), QHash< Key, T >::find(), QHash< Key, T >::insert(), QHash< Key, T >::operator[](), QHash< Key, T >::remove(), and QHash< Key, T >::take().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ emplace() [1/2]

template<typename Key , typename T >
template<typename ... Args>
template< class Key, class T > template< typename ...Args > QHash< Key, T >::iterator QHash< Key, T >::emplace ( const Key key,
Args &&...  args 
)
inline

Definition at line 1304 of file qhash.h.

References args, copy(), QHash< Key, T >::emplace(), and Key.

Referenced by QHash< Key, T >::emplace(), QHash< Key, T >::insert(), QHash< Key, T >::insert(), QSet< T >::insert(), and QTest::TestRegistry::registerTest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ emplace() [2/2]

template<typename Key , typename T >
template<typename ... Args>
template< class Key, class T > template< typename ...Args > QHash< Key, T >::iterator QHash< Key, T >::emplace ( Key &&  key,
Args &&...  args 
)
inline

Inserts a new element into the container.

This new element is constructed in-place using args as the arguments for its construction.

Returns an iterator pointing to the new element.

Definition at line 1311 of file qhash.h.

References args, copy(), d, QHash< Key, T >::detach(), and QHash< Key, T >::isDetached().

+ Here is the call graph for this function:

◆ empty()

template<typename Key , typename T >
template< class Key, class T > bool QHash< Key, T >::empty ( ) const
inlinenoexcept

This function is provided for STL compatibility.

It is equivalent to isEmpty(), returning true if the hash is empty; otherwise returns false.

Definition at line 1329 of file qhash.h.

References QHash< Key, T >::isEmpty().

Referenced by QQmlIncubatorPrivate::incubate(), and QQuickStackElement::initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end() [1/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_iterator QHash< Key, T >::end ( ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1207 of file qhash.h.

◆ end() [2/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::iterator QHash< Key, T >::end ( )
inlinenoexcept

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the hash.

See also
begin(), constEnd()

Definition at line 1206 of file qhash.h.

Referenced by QQuickDesignerSupport::~QQuickDesignerSupport(), QQuickSmoothedAnimationPrivate::~QQuickSmoothedAnimationPrivate(), QQuickTimeLine::~QQuickTimeLine(), QSmoothedAnimation::~QSmoothedAnimation(), QSpringAnimation::~QSpringAnimation(), QWindowsDirectWriteFontDatabase::~QWindowsDirectWriteFontDatabase(), QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(), QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QQuickTimeLinePrivate::add(), QQuickTimeLinePrivate::advance(), QV4DebuggerAgent::breakPointIds(), QGeoTiledMapScenePrivate::buildGeometry(), QGraphicsScenePrivate::cancelGesturesForChildren(), QSet< T >::cend(), QXcbCursor::changeCursor(), QSqlDatabasePrivate::cleanConnections(), QWaylandTextureSharingExtension::cleanupBuffers(), QSSGRhiContext::cleanupDrawCallData(), QNetworkAccessCache::clear(), QQmlTypeLoader::clearCache(), QHash< Key, T >::constKeyValueEnd(), LinuxDmabufClientBufferIntegration::createBufferFor(), QD3D11Buffer::destroy(), QRhiGles2::dispatch(), QRhiVulkan::dispatch(), QAndroidStyle::drawComplexControl(), QAndroidStyle::drawControl(), QAndroidStyle::drawPrimitive(), QAbstractItemViewPrivate::editorForIndex(), QSet< T >::end(), QV4::MultiplyWrappedQObjectMap::end(), QSet< T >::end(), QMetaStringTable::enter(), QQmlJSScope::enumeration(), QQuickWorkerScriptEnginePrivate::event(), QBackingStoreRhiSupportWindowWatcher::eventFilter(), QMimeXMLProvider::excludeMimeTypeGlobs(), QHash< Key, T >::find(), QHash< Key, T >::find(), QGraphicsScenePrivate::gestureEventHandler(), QSSGRenderer::getShaderPipelineForDefaultMaterial(), QTest::TestRegistry::getTestEntryFunction(), QAndroidStyle::hitTestComplexControl(), QAbstractItemViewPrivate::indexForEditor(), QCtfLibImpl::initializeTracepoint(), QSGRhiAtlasTexture::Manager::invalidate(), QSGDefaultRenderContext::invalidateGlyphCaches(), QSimplexConstraint::invert(), QHash< Key, T >::keyEnd(), QHash< Key, T >::keys(), QHash< Key, T >::keyValueEnd(), QHash< Key, T >::keyValueEnd(), QQuickPixmap::load(), QQuickPixmap::loadImageFromDevice(), QQuickTextDocumentWithImageResources::loadPixmap(), QEventDispatcherUNIXPrivate::markPendingSocketNotifiers(), VDMAbstractItemModelDataType::notify(), QHash< Key, T >::operator==(), QXcbEventQueue::peekEventQueue(), QWindowsCursor::pixmapWindowCursor(), QTextureGlyphCache::populate(), QWindowsDirectWriteFontDatabase::populateFamily(), QSGMaterialShaderPrivate::prepare(), QSGDefaultRenderContext::preprocess(), QQmlFindUsagesSupport::process(), processNode(), QQmlJSScope::property(), pullFiles(), QSvgIconEngine::read(), readDependencies(), Graph< Vertex, EdgeData >::removeDirectedEdge(), QGraphicsScenePrivate::removeItemHelper(), QAndroidPlatformMenuBar::removeMenu(), QAndroidPlatformMenu::removeMenuItem(), QFseventsFileSystemWatcherEngine::removePaths(), QQmlComponentPrivate::removePropertyFromRequired(), QWindowsContext::removeWindow(), QQuickWorkerScriptEngine::removeWorkerScript(), Preprocessor::resolveInclude(), QQuickWorkerScriptEngine::run(), AnchorsValidatorPass::run(), QSSGShaderLibraryManager::setShaderSource(), QQmlTableModelColumn::setterAtRole(), QQmlDMAbstractItemModelData::setValue(), QSSGCustomMaterialSystem::shadersForCustomMaterial(), QAndroidStyle::sizeFromContents(), QWindowsCursor::standardWindowCursor(), QAndroidStyle::subControlRect(), QAndroidStyle::subElementRect(), ListModel::sync(), QQuickTimeLine::sync(), QQuickTimeLine::sync(), QSocks5BindStore::timerEvent(), QQmlTypeLoader::trimCache(), QD3D11Buffer::unorderedAccessView(), QQuickSpringAnimationPrivate::updateMode(), QQuickItemViewPrivate::updateUnrequestedIndexes(), VDMAbstractItemModelDataType::value(), QHash< Key, T >::values(), and QQuickWorkerScriptEnginePrivate::workerEngine().

◆ equal_range() [1/2]

template<typename Key , typename T >
QPair< iterator, iterator > QHash< Key, T >::equal_range ( const Key key)
inline

Definition at line 1237 of file qhash.h.

References QHash< Key, T >::find(), and qMakePair().

+ Here is the call graph for this function:

◆ equal_range() [2/2]

template<typename Key , typename T >
QPair< const_iterator, const_iterator > QHash< Key, T >::equal_range ( const Key key) const
inlinenoexcept

Definition at line 1246 of file qhash.h.

References QHash< Key, T >::find(), and qMakePair().

+ Here is the call graph for this function:

◆ erase()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::iterator QHash< Key, T >::erase ( const_iterator  pos)
inline
Since
5.7

Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator to the next item in the hash.

This function never causes QHash 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:

...
QHash<QObject *, int>::iterator i = objectHash.find(obj);
while (i != objectHash.end() && i.key() == obj) {
if (i.value() == 0) {
i = objectHash.erase(i);
} else {
++i;
}
}
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition qhash.h:1258
iterator erase(const_iterator it)
Definition qhash.h:1223
QHash() noexcept=default
Constructs an empty hash.
\inmodule QtCore
Definition qobject.h:90
GLhandleARB obj
[2]
See also
remove(), take(), find()

Definition at line 1223 of file qhash.h.

References QHash< Key, T >::constEnd(), d, QHash< Key, T >::detach(), i, QHashPrivate::Data< Node >::Bucket::isUnused(), it, Q_ASSERT, and QHashPrivate::Data< Node >::Bucket::toBucketIndex().

Referenced by QSmoothedAnimation::~QSmoothedAnimation(), QSpringAnimation::~QSpringAnimation(), QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(), QWidgetAnimator::abort(), QQuickTimeLinePrivate::advance(), QWaylandTextureSharingExtension::cleanupBuffers(), QSSGRhiContext::cleanupDrawCallData(), QRhiGles2::dispatch(), QRhiVulkan::dispatch(), QSet< T >::erase(), QV4::MultiplyWrappedQObjectMap::erase(), QQuickWorkerScriptEnginePrivate::event(), QBackingStoreRhiSupportWindowWatcher::eventFilter(), QSGDefaultRenderContext::invalidateGlyphCaches(), QWindowsCursor::pixmapWindowCursor(), QSGMaterialShaderPrivate::prepare(), QQuickShaderEffectPrivate::propertyChanged(), qt_debug_print_texture_count(), readDependencies(), QItemEditorFactory::registerEditor(), QFreetypeFace::release(), Graph< Vertex, EdgeData >::removeDirectedEdge(), QAbstractItemViewPrivate::removeEditor(), QGraphicsScenePrivate::removeItemHelper(), QAndroidPlatformMenuBar::removeMenu(), QAndroidPlatformMenu::removeMenuItem(), QFseventsFileSystemWatcherEngine::removePaths(), QXcbEventQueue::removePeekerId(), QQmlComponentPrivate::removePropertyFromRequired(), QWindowsContext::removeWindow(), QSocks5BindStore::retrieve(), QSocks5BindStore::timerEvent(), and QQmlTypeLoader::trimCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find() [1/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::iterator QHash< Key, T >::find ( const Key key)
inline

Returns an iterator pointing to the item with the key in the hash.

If the hash contains no item with the key, the function returns end().

If the hash contains multiple items with the key, 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:

...
QHash<QString, int>::const_iterator i = hash.find("HDR");
while (i != hash.end() && i.key() == "HDR") {
cout << i.value() << endl;
++i;
}
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
See also
value(), values()

Definition at line 1258 of file qhash.h.

References d, QHash< Key, T >::detach(), QHash< Key, T >::end(), QHash< Key, T >::isEmpty(), and it.

Referenced by QSmoothedAnimation::~QSmoothedAnimation(), QSpringAnimation::~QSpringAnimation(), QQuickTimeLinePrivate::add(), QGeoTiledMapScenePrivate::buildGeometry(), QXcbCursor::changeCursor(), QHash< Key, T >::constFind(), QSGRhiAtlasTexture::Manager::create(), LinuxDmabufClientBufferIntegration::createBufferFor(), QAndroidStyle::drawComplexControl(), QAndroidStyle::drawControl(), QAndroidStyle::drawPrimitive(), QAbstractItemViewPrivate::editorForIndex(), QMetaStringTable::enter(), QQmlJSScope::enumeration(), QHash< Key, T >::equal_range(), QHash< Key, T >::equal_range(), QQuickWorkerScriptEnginePrivate::event(), QBackingStoreRhiSupportWindowWatcher::eventFilter(), QMimeXMLProvider::excludeMimeTypeGlobs(), fileArchitecture(), QSet< T >::find(), QSet< T >::find(), getQtLibsFromElf(), QSSGRenderer::getShaderPipelineForDefaultMaterial(), QTest::TestRegistry::getTestEntryFunction(), QAndroidStyle::hitTestComplexControl(), QAbstractItemViewPrivate::indexForEditor(), QCtfLibImpl::initializeTracepoint(), QQuickPixmap::load(), QQuickPixmap::loadImageFromDevice(), QQuickTextDocumentWithImageResources::loadPixmap(), QEventDispatcherUNIXPrivate::markPendingSocketNotifiers(), VDMAbstractItemModelDataType::notify(), QPMCache::object(), QHash< Key, T >::operator==(), QXcbEventQueue::peekEventQueue(), QWindowsCursor::pixmapWindowCursor(), QWindowsDirectWriteFontDatabase::populateFamily(), QSGMaterialShaderPrivate::prepare(), QQmlFindUsagesSupport::process(), processNode(), QQmlJSScope::property(), pullFiles(), Graph< Vertex, EdgeData >::removeDirectedEdge(), QFseventsFileSystemWatcherEngine::removePaths(), QQmlComponentPrivate::removePropertyFromRequired(), QWindowsContext::removeWindow(), QQuickWorkerScriptEngine::removeWorkerScript(), Preprocessor::resolveInclude(), QSSGShaderLibraryManager::setShaderSource(), QQmlTableModelColumn::setterAtRole(), QQmlDMAbstractItemModelData::setValue(), QSSGCustomMaterialSystem::shadersForCustomMaterial(), QAndroidStyle::sizeFromContents(), QWindowsCursor::standardWindowCursor(), QAndroidStyle::subControlRect(), QAndroidStyle::subElementRect(), ListModel::sync(), QQuickTimeLine::sync(), QQuickTimeLine::sync(), QD3D11Buffer::unorderedAccessView(), VDMAbstractItemModelDataType::value(), and QQuickWorkerScriptEnginePrivate::workerEngine().

+ Here is the call graph for this function:

◆ find() [2/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_iterator QHash< Key, T >::find ( const Key key) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1270 of file qhash.h.

References d, QHash< Key, T >::end(), QHash< Key, T >::isEmpty(), and it.

+ Here is the call graph for this function:

◆ insert() [1/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::iterator QHash< Key, T >::insert ( const Key key,
const T &  value 
)
inline

Inserts a new item with the key and a value of value.

If there is already an item with the key, that item's value is replaced with value.

Definition at line 1283 of file qhash.h.

References QHash< Key, T >::emplace().

Referenced by DarwinBluetooth::AdvertisementData::AdvertisementData(), LinuxDmabufClientBufferIntegration::LinuxDmabufClientBufferIntegration(), QDBusConnectionPrivate::QDBusConnectionPrivate(), QHaikuCursor::QHaikuCursor(), QHash< Key, T >::QHash(), QHash< Key, T >::QHash(), QNetworkReplyPrivate::QNetworkReplyPrivate(), QQuick3DParticleSpriteParticle::QQuick3DParticleSpriteParticle(), QQuickPackageAttached::QQuickPackageAttached(), Python::WriteImports::WriteImports(), QQmlInstantiatorPrivate::_q_modelUpdated(), QQmlSettingsPrivate::_q_propertyChanged(), QSocks5BindStore::add(), QQuickTimeLinePrivate::add(), QMimeXMLProvider::addAlias(), TestHTTPServer::addAlias(), QV4DebuggerAgent::addBreakPoint(), QPdfEnginePrivate::addConstantAlphaObject(), QSqlDatabasePrivate::addDatabase(), QAbstractItemViewPrivate::addEditor(), QNetworkAccessCache::addEntry(), QSvgIconEngine::addFile(), QSvgFont::addGlyph(), QPdfEnginePrivate::addImage(), QGraphicsAnchorLayoutPrivate::addInternalVertex(), QSSGMaterialVertexPipeline::addInterpolationParameter(), QMimeXMLProvider::addMimeType(), QSvgTinyDocument::addNamedNode(), QSvgTinyDocument::addNamedStyle(), QSGAbstractSoftwareRenderer::addNodeMapping(), QCommandLineParser::addOption(), QInotifyFileSystemWatcherEngine::addPaths(), QKqueueFileSystemWatcherEngine::addPaths(), QSvgIconEngine::addPixmap(), TestHTTPServer::addRedirect(), QQmlDebugServerImpl::addService(), QSvgTinyDocument::addSvgFont(), QGeoTiledMapScenePrivate::addTile(), AttachedPropertyTypeValidatorPass::addWarning(), QWindowsContext::addWindow(), QDirectFbInput::addWindow(), QQmlInspectorServiceImpl::addWindow(), QXcbConnection::addWindowEventListener(), QQuickAnimatorController::beforeNodeSync(), QXcbCursor::changeCursor(), QHaikuCursor::changeCursor(), QQmlPropertyCache::checksum(), QQmlTypeCompiler::compile(), QSSGShaderCache::compileForRhi(), QRhiGles2::compileShader(), QSSGRhiContext::computePipeline(), QV4::ExecutionEngine::consoleCountHelper(), QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints(), QSGRhiAtlasTexture::Manager::create(), QDialogButtonBoxPrivate::createButton(), QWasmIntegration::createPlatformBackingStore(), QQmlOpenMetaObjectType::createProperties(), QQmlOpenMetaObjectType::createProperty(), createSlack(), QLowEnergyControllerPrivateBluezDBus::discoverServices(), QSGDefaultRenderContext::distanceFieldGlyphCache(), QCtfLibImpl::doTracepoint(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QGraphicsScenePrivate::drawSubtreeRecursive(), QPdfEnginePrivate::drawTextItem(), QSSGRhiContext::dummyTexture(), QMetaStringTable::enter(), QSGRhiShaderLinker::feedSamplers(), QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QWindowsDirect2DPaintEnginePrivate::fontFaceFromFontEngine(), QIcc::fromIccProfile(), QConfFile::fromName(), QmlIR::QmlUnitGenerator::generate(), QXcbEventQueue::generatePeekerId(), QGraphicsScenePrivate::gestureEventHandler(), QSSGAssetImportManager::getAllOptions(), QFreetypeFace::getFace(), QSSGShaderLibraryManager::getIncludeContents(), QSSGQmlUtilities::getObjectPropertiesMap(), QQmlTypeLoader::getQmldir(), QQmlTypeLoader::getScript(), QSSGRenderer::getShaderPipelineForDefaultMaterial(), QSSGAssetImportManager::getSupportedExtensions(), QCocoaTouch::getTouchDevice(), QQmlTypeLoader::getType(), QDialogButtonBoxPrivate::handleButtonShowAndHide(), importImp(), QQmlJSImporter::importQmldirs(), QLowEnergyControllerPrivateBluez::init(), QNetworkReplyHttpImplPrivate::initCacheSaveDevice(), QNetworkReplyImplPrivate::initCacheSaveDevice(), initDefaultPaths(), QPlaceManagerEngineNokiaV2::initializeCategories(), VDMAbstractItemModelDataType::initializeMetaType(), QCtfLibImpl::initializeTracepoint(), QApplicationPrivate::initializeWidgetFontHash(), QQmlPropertyMap::insert(), QSet< T >::insert(), QSGOpenVGFontGlyphCacheManager::insertCache(), QColorOutputPrivate::insertColor(), QAndroidPlatformMenuBar::insertMenu(), QDBusPlatformMenu::insertMenuItem(), QAndroidPlatformMenu::insertMenuItem(), QQuickParticleDataHeap::insertTimed(), QQuickContext2DRenderThread::instance(), QQuickPixmapReader::instance(), QWaylandIviApplicationPrivate::ivi_application_surface_create(), QDefaultOutputMapping::load(), QSSGShaderCache::loadBuiltinForRhi(), QPpdPrintDevice::loadPageSizes(), QCocoaPrintDevice::loadPageSizes(), QQuickTextDocumentWithImageResources::loadPixmap(), loadTzTimeZones(), QCocoaPrintDevice::macPaper(), QSSGShaderCache::newPipelineFromPregenerated(), QWinRTLowEnergyServiceHandler::obtainCharList(), QDBusSnippets::operator>>(), operator>>(), QGraphicsView::paintEvent(), Moc::parse(), Moc::parseClassHead(), parseServerList(), QSSGRhiContext::pipeline(), QWindowsCursor::pixmapWindowCursor(), QTextureGlyphCache::populate(), QWindowsDirectWriteFontDatabase::populateFontDatabase(), QQmlFindUsagesSupport::process(), QQuickTableViewPrivate::processLoadRequest(), QQmlMetaTypeData::propertyCache(), QQuickShaderEffectPrivate::propertyChanged(), qt_debug_add_texture(), qt_mac_createRolePalettes(), QSvgIconEngine::read(), readInputFile(), SharedTextureRegistry::receiveBuffer(), QNetworkReplyImplPrivate::redirectionRequested(), QQuickDesignerSupport::refFromEffectItem(), QCtfLibImpl::registerMetadata(), QQuickParticleSystem::registerParticleGroupData(), QCFSocketNotifier::registerSocketNotifier(), QEventDispatcherWin32::registerSocketNotifier(), QQuickWorkerScriptEngine::registerWorkerScript(), QQuickItemViewPrivate::releaseItem(), QGeoTiledMappingManagerEngine::releaseMap(), QGraphicsAnchorLayoutPrivate::removeInternalVertex(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QGeoAreaMonitorPollingPrivate::requestUpdate(), QQmlJSScope::resolveEnums(), Preprocessor::resolveInclude(), QtWaylandClient::QWaylandMimeData::retrieveData_sys(), QQmlListModel::roleNames(), QQmlXmlListModel::roleNames(), QQuickViewTestUtils::QaimModel::roleNames(), QDeclarativeGeocodeModel::roleNames(), QDeclarativeGeoRouteModel::roleNames(), QDeclarativePlaceContentModel::roleNames(), QDeclarativeSearchResultModel::roleNames(), QDeclarativeSearchSuggestionModel::roleNames(), QDeclarativeSupportedCategoriesModel::roleNames(), QQmlJSCodeGenerator::run(), runMoc(), QHeaderViewPrivate::saveCascadingSectionSize(), StaticUnitCache::set(), QNetworkRequest::setAttribute(), QmlLsp::QQmlCodeModel::setBuildPathsForRootUrl(), QCocoaWindow::setContentBorderAreaEnabled(), QNetworkHeadersPrivate::setCookedHeader(), QFontPrivate::setFeature(), QAuthenticator::setOption(), QApplication::setPalette(), QSettings::setPath(), QHighDpiScaling::setScreenFactor(), QSSGShaderLibraryManager::setShaderSource(), QDesktopServices::setUrlHandler(), QSSGCustomMaterialSystem::shadersForCustomMaterial(), QGraphicsAnchorLayoutPrivate::solveMinMax(), QGraphicsAnchorLayoutPrivate::solvePreferred(), QSSGRhiContext::srb(), QWindowsCursor::standardWindowCursor(), QGeoAreaMonitorPollingPrivate::startMonitoring(), QBackingStoreRhiSupport::swapChainForWindow(), ListModel::sync(), QSGRenderContext::textureForFactory(), QGeoTileRequestManagerPrivate::tileError(), QCborMap::toVariantHash(), QWindowsMouseHandler::translateTouchEvent(), QSSGShaderCache::tryNewPipelineFromPersistentCache(), Driver::unique(), QGestureManager::unregisterGestureRecognizer(), QQuick3DSceneManager::updateDirtyResource(), QQuick3DSceneManager::updateDirtySpatialNode(), QGeoTiledMapScene::updateSceneGraph(), QmlLsp::QQmlCodeModel::url2Path(), QQmlJSImportVisitor::visit(), QSvgIconEngine::write(), QTextOdfWriter::writeAll(), QWaylandTextInputPrivate::zwp_text_input_v2_enable(), and QWaylandTextInputV4Private::zwp_text_input_v4_enable().

+ Here is the call graph for this function:

◆ insert() [2/2]

template<typename Key , typename T >
template< class Key, class T > void QHash< Key, T >::insert ( const QHash< Key, T > &  other)
inline
Since
5.15

Inserts all the items in the other hash into this hash.

If a key is common to both hashes, its value will be replaced with the value stored in other.

Definition at line 1288 of file qhash.h.

References d, QHash< Key, T >::detach(), QHash< Key, T >::emplace(), hash, and it.

+ Here is the call graph for this function:

◆ isDetached()

template<typename Key , typename T >
template< class Key, class T > bool QHash< Key, T >::isDetached ( ) const
inlinenoexcept

Returns true if the hash's internal data isn't shared with any other hash object; otherwise returns false.

See also
detach()

Definition at line 946 of file qhash.h.

References d.

Referenced by QHash< Key, T >::emplace(), QSet< T >::isDetached(), QHash< Key, T >::operator[](), and QHash< Key, T >::reserve().

+ Here is the caller graph for this function:

◆ isEmpty()

template<typename Key , typename T >
template< class Key, class T > bool QHash< Key, T >::isEmpty ( ) const
inlinenoexcept

Returns true if the hash contains no items; otherwise returns false.

See also
size()

Definition at line 926 of file qhash.h.

References d.

Referenced by QSGRhiAtlasTexture::Manager::~Manager(), QQuickTextDocumentWithImageResources::~QQuickTextDocumentWithImageResources(), QRhiImplementation::~QRhiImplementation(), QHeaderViewPrivate::adjustedVisualIndex(), QWidgetAnimator::animating(), QEvdevTouchScreenData::assignIds(), QRhiGles2::beginExternal(), QQuickTableViewPrivate::checkForVisibilityChanges(), QGeoAreaMonitorPollingPrivate::checkStartStop(), QAbstractItemViewPrivate::editorForIndex(), QHash< Key, T >::empty(), QHash< Key, T >::find(), QHash< Key, T >::find(), QCocoaTouch::getCurrentTouchPointList(), getPath(), QApplicationPrivate::handlePaletteChanged(), QAbstractItemViewPrivate::hasEditor(), QQmlIncubatorPrivate::incubateCppBasedComponent(), QAbstractItemViewPrivate::indexForEditor(), initDefaultPaths(), PlaceManagerEngineEsri::initializeCategories(), QPlaceManagerEngineMapbox::initializeCategories(), QPlaceManagerEngineOsm::initializeCategories(), QSGSoftwareRenderContext::invalidate(), QQuickTimeLine::isActive(), QSet< T >::isEmpty(), QQmlDelegateModelPrivate::itemsMoved(), QQuickTableViewPrivate::loadAndUnloadVisibleEdges(), QQuickTableViewPrivate::loadInitialTable(), QGraphicsItem::mouseMoveEvent(), QFileSystemModelPrivate::name(), QCocoaTheme::palette(), parseTestArgs(), QTextureGlyphCache::populate(), processNode(), QQuickTableViewPrivate::processRebuildTable(), qt_debug_print_texture_count(), readDependencies(), QLibInputTouch::registerDevice(), QFreetypeFace::release(), QHash< Key, T >::remove(), QFseventsFileSystemWatcherEngine::removePaths(), QKqueueFileSystemWatcherEngine::removePaths(), QXcbEventQueue::removePeekerId(), QQmlSettingsPrivate::reset(), QSocks5BindStore::retrieve(), QQuickTableViewPrivate::scrollTowardsSelectionPoint(), QHeaderViewPrivate::sectionsHiddenToBitVector(), QHeaderViewPrivate::setDefaultSectionSize(), QSettings::setPath(), QQuickTableViewPrivate::setSelectionEndPos(), QQuickTableViewPrivate::setSelectionStartPos(), QQuickTableViewPrivate::syncRebuildOptions(), QQuickTableViewPrivate::syncSyncView(), QQuickTableViewPrivate::tableLayoutToString(), QHash< Key, T >::take(), QGraphicsScenePrivate::touchEventHandler(), QApplicationPrivate::translateRawTouchEvent(), QQuickTableViewPrivate::updateContentHeight(), QQuickTableViewPrivate::updateContentWidth(), QQuickTimeLine::updateCurrentTime(), QSGDistanceFieldGlyphNode::updateGeometry(), updateLibsXml(), QQuickTableViewPrivate::updateTable(), and QSvgIconEngine::virtual_hook().

◆ isSharedWith()

template<typename Key , typename T >
template< class Key, class T > bool QHash< Key, T >::isSharedWith ( const QHash< Key, T > &  other) const
inlinenoexcept

Returns true if the internal hash table of this QHash is shared with other, otherwise false.

Definition at line 947 of file qhash.h.

References d, and other().

+ Here is the call graph for this function:

◆ key() [1/2]

template<typename Key , typename T >
template< class Key, class T > Key QHash< Key, T >::key ( const T &  value) const
inlinenoexcept

Definition at line 1018 of file qhash.h.

References Key.

Referenced by QQmlTableModel::data(), QGestureManager::gesturePending(), QQuickParticleGroupData::name(), and QQmlTableModel::setData().

+ Here is the caller graph for this function:

◆ key() [2/2]

template<typename Key , typename T >
template< class Key, class T > Key QHash< Key, T >::key ( const T &  value,
const Key defaultKey 
) const
inlinenoexcept
Since
4.3

Returns the first key mapped to value. If the hash contains no item mapped to value, returns defaultKey, or a \l{default-constructed value}{default-constructed key} if this parameter has not been supplied.

This function can be slow (\l{linear time}), because QHash's internal data structure is optimized for fast lookup by key, not by value.

Definition at line 1025 of file qhash.h.

◆ keyBegin()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::key_iterator QHash< Key, T >::keyBegin ( ) const
inlinenoexcept
Since
5.6

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first key in the hash.

See also
keyEnd()

Definition at line 1210 of file qhash.h.

References QHash< Key, T >::begin().

Referenced by QHash< Key, T >::keys(), QQuickImageParticle::prepareNextFrame(), QV4DebuggerAgent::removeAllBreakPoints(), and QQuickTableViewPrivate::updateSelectedOnAllDelegateItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ keyEnd()

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::key_iterator QHash< Key, T >::keyEnd ( ) const
inlinenoexcept
Since
5.6

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last key in the hash.

See also
keyBegin()

Definition at line 1211 of file qhash.h.

References QHash< Key, T >::end().

Referenced by QHash< Key, T >::keys(), QQuickImageParticle::prepareNextFrame(), QV4DebuggerAgent::removeAllBreakPoints(), and QQuickTableViewPrivate::updateSelectedOnAllDelegateItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ keys() [1/2]

template<typename Key , typename T >
template< class Key, class T > QList< Key > QHash< Key, T >::keys ( ) const
inline

Returns a list containing all the keys in the hash, in an arbitrary order.

The order is guaranteed to be the same as that used by values().

This function creates a new list, in \l {linear time}. The time and memory use that entails can be avoided by iterating from \l keyBegin() to \l keyEnd().

See also
values(), key()

Definition at line 1076 of file qhash.h.

References QHash< Key, T >::keyBegin(), and QHash< Key, T >::keyEnd().

Referenced by QQmlDebugConnectionPrivate::advertisePlugins(), QDialogButtonBoxPrivate::allButtons(), QmlLsp::QQmlCodeModel::buildPathsForFileUrl(), QPlaceManagerEngineMapbox::childCategoryIds(), QDeclarativeSupportedCategoriesModel::data(), QFont::featureTags(), QGraphicsScenePrivate::gestureEventHandler(), QTest::TestRegistry::getAllTestNames(), QDeclarativeSupportedCategoriesModel::index(), QDeclarativeSupportedCategoriesModel::parent(), parseTestArgs(), QCoreTextFontDatabase::populateFontDatabase(), readInputFile(), readInputFileDirectory(), QDeclarativeSupportedCategoriesModel::rowCount(), QFont::substitutions(), QGestureManager::unregisterGestureRecognizer(), and QGeoTiledMapScene::updateSceneGraph().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ keys() [2/2]

template<typename Key , typename T >
template< class Key, class T > QList< Key > QHash< Key, T >::keys ( const T &  value) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a list containing all the keys associated with value value, in an arbitrary order.

This function can be slow (\l{linear time}), because QHash's internal data structure is optimized for fast lookup by key, not by value.

Definition at line 1077 of file qhash.h.

References QHash< Key, T >::begin(), QHash< Key, T >::end(), and i.

+ Here is the call graph for this function:

◆ keyValueBegin() [1/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::key_value_iterator QHash< Key, T >::keyValueBegin ( )
inline
Since
5.10

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first entry in the hash.

See also
keyValueEnd()

Definition at line 1212 of file qhash.h.

References QHash< Key, T >::begin().

+ Here is the call graph for this function:

◆ keyValueBegin() [2/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_key_value_iterator QHash< Key, T >::keyValueBegin ( ) const
inlinenoexcept
Since
5.10

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry in the hash.

See also
keyValueEnd()

Definition at line 1214 of file qhash.h.

References QHash< Key, T >::begin().

+ Here is the call graph for this function:

◆ keyValueEnd() [1/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::key_value_iterator QHash< Key, T >::keyValueEnd ( )
inline
Since
5.10

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary entry after the last entry in the hash.

See also
keyValueBegin()

Definition at line 1213 of file qhash.h.

References QHash< Key, T >::end().

+ Here is the call graph for this function:

◆ keyValueEnd() [2/2]

template<typename Key , typename T >
template< class Key, class T > QHash< Key, T >::const_key_value_iterator QHash< Key, T >::keyValueEnd ( ) const
inlinenoexcept
Since
5.10

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary entry after the last entry in the hash.

See also
keyValueBegin()

Definition at line 1216 of file qhash.h.

References QHash< Key, T >::end().

+ Here is the call graph for this function:

◆ load_factor()

template<typename Key , typename T >
template< class Key, class T > float QHash< Key, T >::load_factor ( ) const
inlinenoexcept

Returns the current load factor of the QHash's internal hash table.

This is the same as capacity()/size(). The implementation used will aim to keep the load factor between 0.25 and 0.5. This avoids having too many hash table collisions that would degrade performance.

Even with a low load factor, the implementation of the hash table has a very low memory overhead.

This method purely exists for diagnostic purposes and you should rarely need to call it yourself.

See also
reserve(), squeeze()

Definition at line 1324 of file qhash.h.

References d.

◆ max_bucket_count()

template<typename Key , typename T >
static size_t QHash< Key, T >::max_bucket_count ( )
inlinestaticnoexcept

Definition at line 1327 of file qhash.h.

References QHashPrivate::Data< Node >::maxNumBuckets().

+ Here is the call graph for this function:

◆ max_load_factor()

template<typename Key , typename T >
static float QHash< Key, T >::max_load_factor ( )
inlinestaticnoexcept

Definition at line 1325 of file qhash.h.

◆ operator!=()

template<typename Key , typename T >
template<typename AKey = Key, typename AT = T>
template< class Key, class T > bool QHash< Key, T >::operator!= ( const QHash< Key, T > &  other) const
inlinenoexcept

Returns true if other is not equal to this hash; otherwise returns false.

Two hashes are considered equal if they contain the same (key, value) pairs.

This function requires the value type to implement operator==().

See also
operator==()

Definition at line 918 of file qhash.h.

References other().

+ Here is the call graph for this function:

◆ operator=()

template<typename Key , typename T >
template< class Key, class T > QHash & QHash< Key, T >::operator= ( const QHash< Key, T > &  other)
inlinenoexcept

Assigns other to this hash and returns a reference to this hash.

Move-assigns other to this QHash instance.

Since
5.2

Definition at line 858 of file qhash.h.

References d, o, and other().

+ Here is the call graph for this function:

◆ operator==()

template<typename Key , typename T >
template<typename AKey = Key, typename AT = T>
template< class Key, class T > bool QHash< Key, T >::operator== ( const QHash< Key, T > &  other) const
inlinenoexcept

Returns true if other is equal to this hash; otherwise returns false.

Two hashes are considered equal if they contain the same (key, value) pairs.

This function requires the value type to implement operator==().

See also
operator!=()

Definition at line 902 of file qhash.h.

References d, QHash< Key, T >::end(), QHash< Key, T >::find(), i, it, and other().

+ Here is the call graph for this function:

◆ operator[]() [1/2]

template<typename Key , typename T >
template< class Key, class T > T & QHash< Key, T >::operator[] ( const Key key)
inline

Returns the value associated with the key as a modifiable reference.

If the hash contains no item with the key, the function inserts a \l{default-constructed value} into the hash with the key, and returns a reference to it.

See also
insert(), value()

Definition at line 1060 of file qhash.h.

References QHash< Key, T >::QHash(), copy(), QHashPrivate::Node< Key, T >::createInPlace(), d, QHash< Key, T >::detach(), QHash< Key, T >::isDetached(), and Q_ASSERT.

Referenced by QV4::MultiplyWrappedQObjectMap::insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator[]() [2/2]

template<typename Key , typename T >
template< class Key, class T > const T QHash< Key, T >::operator[] ( const Key key) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as value().

Definition at line 1071 of file qhash.h.

◆ remove()

template<typename Key , typename T >
template< class Key, class T > bool QHash< Key, T >::remove ( const Key key)
inline

Removes the item that has the key from the hash.

Returns true if the key exists in the hash and the item has been removed, and false otherwise.

See also
clear(), take()

Definition at line 956 of file qhash.h.

References d, QHash< Key, T >::detach(), QHash< Key, T >::isEmpty(), and it.

Referenced by QConfFileSettingsPrivate::~QConfFileSettingsPrivate(), QOffscreenWindow::~QOffscreenWindow(), QQuickContext2DRenderThread::~QQuickContext2DRenderThread(), QQuickPackageAttached::~QQuickPackageAttached(), QQuickPixmapReader::~QQuickPixmapReader(), SharedTextureRegistry::abandonBuffer(), QQuickAnimatorController::animationFinished(), QParallelAnimationGroupPrivate::animationRemoved(), QtWaylandClient::QWaylandMimeData::appendFormat(), QEvdevTouchScreenData::assignIds(), QQuickAnimatorController::beforeNodeSync(), QQmlTableInstanceModel::cancel(), QGraphicsScenePrivate::cancelGesturesForChildren(), QHeaderViewPrivate::cascadingResize(), QGestureManager::cleanupCachedGestures(), QQuick3DSceneManager::cleanupNodes(), QFontEngine::clearGlyphCache(), QQuickItemViewPrivate::createItem(), QQmlTableInstanceModel::dispose(), QEventDispatcherWin32::doUnregisterSocketNotifier(), QGestureManager::filterEventThroughContexts(), QGraphicsScenePrivate::gestureEventHandler(), QQuickStackLayout::itemChange(), QQmlTableInstanceModel::object(), QQuickParticleDataHeap::pop(), qt_debug_remove_texture(), QQmlTableInstanceModel::release(), QQuickTransformAnimatorHelperStore::release(), QPMCache::releaseKey(), QGeoTiledMappingManagerEngine::releaseMap(), StaticUnitCache::remove(), QSet< T >::remove(), QGeoPositionInfo::removeAttribute(), QGeoSatelliteInfo::removeAttribute(), QWasmIntegration::removeBackingStore(), QV4DebuggerAgent::removeBreakPoint(), LinuxDmabufClientBufferIntegration::removeBuffer(), QDialogButtonBoxPrivate::removeButton(), QAbstractItemViewPrivate::removeEditor(), QQmlDebugServerImpl::removeEngine(), QNetworkAccessCache::removeEntry(), QQuickPixmapData::removeFromCache(), QGraphicsAnchorLayoutPrivate::removeInternalVertex(), QGraphicsScenePrivate::removeItemHelper(), QDBusPlatformMenu::removeMenuItem(), QQmlDebugServerImpl::removeService(), QFont::removeSubstitutions(), QGeoTiledMapScenePrivate::removeTiles(), QDirectFbInput::removeWindow(), QQmlInspectorServiceImpl::removeWindow(), QXcbConnection::removeWindowEventListener(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QGeoTileRequestManagerPrivate::requestTiles(), QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(), QWindowsFileSystemWatcherEngineThread::run(), runMoc(), QNetworkRequest::setAttribute(), QmlLsp::QQmlCodeModel::setBuildPathsForRootUrl(), QNetworkHeadersPrivate::setCookedHeader(), QGraphicsWidgetStyles::setStyleForWidget(), QDesktopServices::setUrlHandler(), QGeoAreaMonitorPollingPrivate::startMonitoring(), QtWaylandClient::QWaylandTextInputMethod::text_input_method_v1_end_input_method_event(), QGeoTileRequestManagerPrivate::tileError(), QGeoTileRequestManagerPrivate::tileFetched(), QNetworkAccessCache::timerEvent(), QWindowsMouseHandler::translateTouchEvent(), QGestureManager::unregisterGestureRecognizer(), QWaylandIviApplicationPrivate::unregisterIviSurface(), QCFSocketNotifier::unregisterSocketNotifier(), QWaylandXdgOutputManagerV1Private::unregisterXdgOutput(), QFontPrivate::unsetFeature(), QSGSoftwareRenderableNodeUpdater::updateNodes(), QmlLsp::QQmlCodeModel::url2Path(), QQmlJSImportVisitor::visit(), and QSGSoftwareRenderLoop::windowDestroyed().

+ Here is the call graph for this function:

◆ removeIf()

template<typename Key , typename T >
template<typename Predicate >
template< class Key, class T > template< typename Predicate > qsizetype QHash< Key, T >::removeIf ( Predicate  pred)
inline
Since
6.1

Removes all elements for which the predicate pred returns true from the hash.

The function supports predicates which take either an argument of type {QHash<Key, T>::iterator}, or an argument of type {std::pair<const Key &, T &>}.

Returns the number of elements removed, if any.

See also
clear(), take()

Definition at line 971 of file qhash.h.

References QtPrivate::associative_erase_if().

+ Here is the call graph for this function:

◆ reserve()

template<typename Key , typename T >
template< class Key, class T > void QHash< Key, T >::reserve ( qsizetype  size)
inline

Ensures that the QHash's internal hash table has space to store at least size items without having to grow the hash table.

This implies that the hash table will contain at least 2 * size buckets to ensure good performance

This function is useful for code that needs to build a huge hash and wants to avoid repeated reallocation. For example:

hash.reserve(20000);
for (int i = 0; i < 20000; ++i)
hash.insert(keys[i], values[i]);
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
Definition qhash.h:1076
GLenum GLsizei GLsizei GLint * values
[15]

Ideally, size should be the maximum number of items expected in the hash. QHash will then choose the smallest possible number of buckets that will allow storing size items in the table without having to grow the internal hash table. If size is an underestimate, the worst that will happen is that the QHash will be a bit slower.

In general, you will rarely ever need to call this function. QHash's internal hash table automatically grows to provide good performance without wasting too much memory.

See also
squeeze(), capacity()

Definition at line 929 of file qhash.h.

References QHash< Key, T >::capacity(), d, QHashPrivate::Data< Node >::detached(), and QHash< Key, T >::isDetached().

Referenced by QSGRhiShaderLinker::reset(), QHash< Key, T >::squeeze(), and QCborMap::toVariantHash().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

◆ squeeze()

template<typename Key , typename T >
template< class Key, class T > void QHash< Key, T >::squeeze ( )
inline

Reduces the size of the QHash's internal hash table to save memory.

The sole purpose of this function is to provide a means of fine tuning QHash's memory usage. In general, you will rarely ever need to call this function.

See also
reserve(), capacity()

Definition at line 939 of file qhash.h.

References QHash< Key, T >::capacity(), and QHash< Key, T >::reserve().

Referenced by QSet< T >::squeeze().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

template<typename Key , typename T >
template< class Key, class T > void QHash< Key, T >::swap ( QHash< Key, T > &  other)
inlinenoexcept
Since
4.8

Swaps hash other with this hash. This operation is very fast and never fails.

Definition at line 898 of file qhash.h.

References d, other(), and qt_ptr_swap().

Referenced by QQmlMetaTypeData::~QQmlMetaTypeData(), QQmlMetaType::clearTypeRegistrations(), and QSet< T >::swap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ take()

template<typename Key , typename T >
template< class Key, class T > T QHash< Key, T >::take ( const Key key)
inline

Removes the item with the key from the hash and returns the value associated with it.

If the item does not exist in the hash, the function simply returns a \l{default-constructed value}.

If you don't use the return value, remove() is more efficient.

See also
remove()

Definition at line 975 of file qhash.h.

References d, QHash< Key, T >::detach(), QHash< Key, T >::isEmpty(), and it.

Referenced by QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), QSqlDatabasePrivate::addDatabase(), QQuickDesignerSupport::derefFromEffectItem(), QDialogButtonBoxPrivate::handleButtonShowAndHide(), QSSGRhiContext::releaseDrawCallData(), QPMCache::remove(), QDBusConnectionManager::removeConnection(), QSqlDatabasePrivate::removeDatabase(), QInotifyFileSystemWatcherEngine::removePaths(), QKqueueFileSystemWatcherEngine::removePaths(), QQmlWatcher::removeWatch(), QGeoAreaMonitorPollingPrivate::stopMonitoring(), QV4::ExecutionEngine::stopTimer(), QWaylandQtTextInputMethodPrivate::text_input_method_v1_disable(), QtWaylandClient::QWaylandTextInputMethod::text_input_method_v1_end_input_method_event(), QSGRenderContext::textureFactoryDestroyed(), QQuickTableViewPrivate::unloadItem(), QGeoTiledMapScene::updateSceneGraph(), QWaylandTextInputPrivate::zwp_text_input_v2_disable(), and QWaylandTextInputV4Private::zwp_text_input_v4_disable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ value() [1/2]

template<typename Key , typename T >
template< class Key, class T > T QHash< Key, T >::value ( const Key key) const
inlinenoexcept

Definition at line 1044 of file qhash.h.

Referenced by QMenuPrivate::_q_actionTriggered(), QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead(), QNetworkReplyImplPrivate::_q_copyReadyRead(), QQmlInstantiatorPrivate::_q_modelUpdated(), QMenuPrivate::_q_platformMenuAboutToShow(), QHeaderViewPrivate::_q_sectionsAboutToBeChanged(), CPP::WriteInitialization::acceptWidget(), QQuickTransformAnimatorHelperStore::acquire(), QSvgIconEngine::actualSize(), QPdfEnginePrivate::addConstantAlphaObject(), QNetworkAccessCache::addEntry(), QPdfEnginePrivate::addImage(), QGraphicsAnchorLayoutPrivate::addInternalVertex(), QMimeXMLProvider::addParents(), API_AVAILABLE(), QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions(), QCocoaWindow::applyContentBorderThickness(), QNetworkRequest::attribute(), QOffscreenBackingStore::backingStoreForWinId(), SharedTextureRegistry::bufferForId(), QmlLsp::QQmlCodeModel::buildPathsForRootUrl(), buttonValueToEnum(), QSGOpenVGFontGlyphCacheManager::cache(), QQmlTableInstanceModel::cancel(), QGraphicsScenePrivate::cancelGesturesForChildren(), QHeaderViewPrivate::cascadingResize(), PlaceManagerEngineEsri::category(), QPlaceManagerEngineMapbox::category(), QPlaceManagerEngineOsm::category(), QHaikuCursor::changeCursor(), PlaceManagerEngineEsri::childCategories(), QPlaceManagerEngineOsm::childCategories(), PlaceManagerEngineEsri::childCategoryIds(), QPlaceManagerEngineOsm::childCategoryIds(), QFontCache::clear(), QColorOutputPrivate::color(), QMimeType::comment(), QDBusConnectionManager::connection(), QV4::ExecutionEngine::consoleCountHelper(), LinuxDmabufClientBufferIntegration::createBufferFor(), QItemEditorFactory::createEditor(), QWasmIntegration::createPlatformWindow(), QDeclarativeSupportedCategoriesModel::data(), CustomDataProxy::data(), QQmlTableModel::data(), QGraphicsItem::data(), QAuthenticatorPrivate::digestMd5Response(), QSGDefaultRenderContext::distanceFieldGlyphCache(), QEventDispatcherWin32::doUnregisterSocketNotifier(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QMacStyle::drawControl(), QPdfEnginePrivate::drawTextItem(), QQuickPixmapReader::existingInstance(), QCoreTextFontDatabase::fallbacksForFamily(), QFont::featureValue(), QSGRhiShaderLinker::feedSamplers(), QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QWindowsContext::findClosestPlatformWindow(), QWindowsContext::findPlatformWindow(), QNetworkReplyHttpImplPrivate::finished(), QNetworkReplyImplPrivate::finished(), QWindowsDirect2DPaintEnginePrivate::fontFaceFromFontEngine(), QConfFile::fromName(), QmlIR::QmlUnitGenerator::generate(), QT_BEGIN_NAMESPACE::generateMeshLevelsOfDetail(), QGraphicsScenePrivate::gestureEventHandler(), QFreetypeFace::getFace(), QQuick3DPhysicsHeightFieldManager::getHeightField(), QQuick3DPhysicsMeshManager::getMesh(), getPath(), QQmlTypeLoader::getQmldir(), QQmlTypeLoader::getScript(), QCocoaTouch::getTouchDevice(), QQmlTypeLoader::getType(), QOffscreenBackingStore::grabWindow(), QQuickPackage::hasPart(), QNetworkRequest::header(), QNetworkProxy::header(), QQmlEnginePrivate::imageProvider(), importImp(), QQmlTableInstanceModel::incubationStatus(), QDeclarativeSupportedCategoriesModel::index(), QQuickContext2DRenderThread::instance(), QQuickPixmapReader::instance(), QParallelAnimationGroupPrivate::isUncontrolledAnimationFinished(), QSGRhiShaderLinker::linkTextureSubRects(), QQuickTableViewPrivate::loadedTableItem(), QCocoaPrintDevice::macPaper(), Preprocessor::macroExpandIdentifier(), QGraphicsScenePrivate::markDirty(), QMimeAllGlobPatterns::matchingGlobs(), QAndroidPlatformMenuBar::menuForId(), QDBusMenuBar::menuForTag(), QAndroidPlatformMenu::menuItemForId(), QMimeXMLProvider::mimeTypeForName(), QGraphicsItem::mouseMoveEvent(), QFileSystemModelPrivate::name(), QSvgTinyDocument::namedNode(), QSvgTinyDocument::namedStyle(), QQmlNativeDebugConnector::open(), QAuthenticator::option(), QFontFamilyDelegate::paint(), QCocoaTheme::palette(), PlaceManagerEngineEsri::parentCategoryId(), parseBrushValue(), QAuthenticatorPrivate::parseDigestAuthenticationChallenge(), QAuthenticatorPrivate::parseHttpResponse(), parseServerList(), QQuickPackage::part(), QSvgIconEngine::pixmap(), QXcbConnection::platformWindowFromId(), QCoreTextFontDatabase::populateFontDatabase(), QPpdPrintDevice::printableMargins(), QCocoaPrintDevice::printableMargins(), QQmlMetaTypeData::propertyCache(), qt_aqua_get_known_size(), qt_debug_remove_texture(), QQuickParticleEmitter::reclaculateGroupId(), QGestureManager::recycle(), QCFSocketNotifier::registerSocketNotifier(), QNetworkAccessCache::releaseEntry(), QGraphicsAnchorLayoutPrivate::removeAnchor(), QV4DebuggerAgent::removeBreakPoint(), QNetworkAccessCache::removeEntry(), QGraphicsAnchorLayoutPrivate::removeInternalVertex(), QFseventsFileSystemWatcherEngine::removePaths(), QQmlDebugServerImpl::removeService(), QSGAbstractSoftwareRenderer::renderableNode(), QQuickDesignerSupport::renderImageForItem(), QNetworkReplyHttpImplPrivate::replyDownloadData(), QNetworkAccessCache::requestEntryNow(), QMimeXMLProvider::resolveAlias(), QV4::ExecutableCompilationUnit::resolvedType(), QQmlTypeCompiler::resolvedType(), SignalHandlerResolver::resolveSignalHandlerExpressions(), QDeclarativeSupportedCategoriesModel::rowCount(), QDefaultOutputMapping::screenNameForDeviceNode(), QMenuPrivate::scrollMenu(), QGtk3FileDialogHelper::selectedNameFilter(), QGtk3FileDialogHelper::selectNameFilter(), QSqlRelationalTableModel::selectStatement(), QNetworkReplyHttpImplPrivate::sendCacheContents(), QEventDispatcherWin32Private::sendTimerEvent(), QQmlDebugServerImpl::service(), QQuickTableViewPrivate::setCurrentIndexFromKeyEvent(), QQmlTableModel::setData(), QQmlTableInstanceModel::setRequiredProperty(), QSGRhiDistanceFieldGlyphCache::storeGlyphs(), QGraphicsWidgetStyles::styleForWidget(), QMacStyle::subControlRect(), QFont::substitutes(), QSGRenderContext::textureForFactory(), QCoreTextFontDatabase::themeFont(), QGeoTileRequestManagerPrivate::tileError(), QDBusConnectionPrivate::timerEvent(), QWindowsMouseHandler::translateTouchEvent(), QSvgIconEnginePrivate::tryLoad(), QSGRenderContext::unregisterFontengineForCleanup(), QGestureManager::unregisterGestureRecognizer(), QCFSocketNotifier::unregisterSocketNotifier(), QFontCache::updateHitCountAndTimeStamp(), QGraphicsItemPrivate::updatePaintedViewBoundingRects(), QmlLsp::QQmlCodeModel::url2Path(), QQmlToolingSettings::value(), QItemEditorFactory::valuePropertyName(), QCommandLineParser::values(), QV4::Compiler::Codegen::visit(), QQnxIntegration::window(), QXcbConnection::windowEventListenerFromId(), QOffscreenWindow::windowForWinId(), QSvgIconEngine::write(), QTextOdfWriter::writeAll(), QTextOdfWriter::writeTableCellFormat(), and QXcbCursor::xcbCursor().

◆ value() [2/2]

template<typename Key , typename T >
template< class Key, class T > T QHash< Key, T >::value ( const Key key,
const T &  defaultValue 
) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the value associated with the key.

If the hash contains no item with the key, the function returns defaultValue, or a \l{default-constructed value} if this parameter has not been supplied.

Definition at line 1052 of file qhash.h.

◆ values()

template<typename Key , typename T >
template< class Key, class T > QList< T > QHash< Key, T >::values ( ) const
inline

Returns a list containing all the values in the hash, in an arbitrary order.

The order is guaranteed to be the same as that used by keys().

This function creates a new list, in \l {linear time}. The time and memory use that entails can be avoided by iterating from \l keyValueBegin() to \l keyValueEnd().

See also
keys(), value()

Definition at line 1088 of file qhash.h.

References QHash< Key, T >::begin(), and QHash< Key, T >::end().

Referenced by QGeoAreaMonitorPolling::activeMonitors(), QMimeXMLProvider::addAllMimeTypes(), QPlaceManagerEngineMapbox::childCategories(), QQuickTableViewPrivate::dumpTable(), and QTextLayout::glyphRuns().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ const_iterator

template<typename Key , typename T >
friend class const_iterator
friend

Definition at line 1172 of file qhash.h.

◆ erase_if()

template<typename Key , typename T >
template< typename Key, typename T, typename Predicate > qsizetype erase_if ( QHash< Key, T > &  hash,
Predicate  pred 
)
related
Since
6.1

Removes all elements for which the predicate pred returns true from the hash hash.

The function supports predicates which take either an argument of type {QHash<Key, T>::iterator}, or an argument of type {std::pair<const Key &, T &>}.

Returns the number of elements removed, if any.

Definition at line 2223 of file qhash.h.

References QtPrivate::associative_erase_if(), and hash.

+ Here is the call graph for this function:

◆ iterator

template<typename Key , typename T >
friend class iterator
friend

Definition at line 1132 of file qhash.h.

◆ operator<<()

template<typename Key , typename T >
template< class Key, class T > QDataStream & operator<< ( QDataStream out,
const QHash< Key, T > &  hash 
)
related

Writes the hash hash to stream out.

This function requires the key and value types to implement operator<<().

See also
{Serializing Qt Data Types}

Definition at line 436 of file qdatastream.h.

References hash, and QtPrivate::readAssociativeContainer().

+ Here is the call graph for this function:

◆ operator>>()

template<typename Key , typename T >
template< class Key, class T > QDataStream & operator>> ( QDataStream in,
QHash< Key, T > &  hash 
)
related

Reads a hash from stream in into hash.

This function requires the key and value types to implement operator>>().

See also
{Serializing Qt Data Types}

Definition at line 436 of file qdatastream.h.

◆ qHash() [1/40]

template<typename Key , typename T >
size_t qHash ( char  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 81 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [2/40]

template<typename Key , typename T >
size_t qHash ( char16_t  key,
size_t  seed = 0 
)
related
Since
6.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 120 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [3/40]

template<typename Key , typename T >
size_t qHash ( char32_t  key,
size_t  seed = 0 
)
related
Since
6.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 122 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [4/40]

template<typename Key , typename T >
size_t qHash ( char8_t  key,
size_t  seed = 0 
)
related
Since
6.0

Returns the hash value for the key, using seed to seed the calculation.

◆ qHash() [5/40]

template<typename Key , typename T >
size_t qHash ( const QBitArray key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 966 of file qhash.cpp.

◆ qHash() [6/40]

template<typename Key , typename T >
size_t qHash ( const QByteArray key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 148 of file qhashfunctions.h.

References qHash(), qToByteArrayViewIgnoringNull(), and seed.

+ Here is the call graph for this function:

◆ qHash() [7/40]

template<typename Key , typename T >
size_t qHash ( const QByteArrayView key,
size_t  seed = 0 
)
related
Since
6.0

Returns the hash value for the key, using seed to seed the calculation.

◆ qHash() [8/40]

template<typename Key , typename T >
size_t qHash ( const QChar  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 141 of file qhashfunctions.h.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [9/40]

template<typename Key , typename T >
size_t qHash ( const QDateTime key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 5688 of file qdatetime.cpp.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [10/40]

template<typename Key , typename T >
size_t qHash ( const QGeoCoordinate coordinate,
size_t  seed = 0 
)
related

Returns a hash value for coordinate, using seed to seed the calculation.

Definition at line 746 of file qgeocoordinate.cpp.

References QGeoCoordinate::altitude, hash, QGeoCoordinate::latitude, QGeoCoordinate::longitude, and seed.

◆ qHash() [11/40]

template<typename Key , typename T >
template< class Key, class T > size_t qHash ( const QHash< Key, T > &  key,
size_t  seed = 0 
)
related
Since
5.8

Returns the hash value for the key, using seed to seed the calculation.

Type T must be supported by qHash().

Definition at line 2195 of file qhash.h.

References QSet< T >::begin(), hash, it, and seed.

+ Here is the call graph for this function:

◆ qHash() [12/40]

template<typename Key , typename T >
size_t qHash ( const QOcspResponse response,
size_t  seed 
)
related

Returns the hash value for the response, using seed to seed the calculation.

Since
5.13

Definition at line 209 of file qocspresponse.cpp.

References d, hash, Q_ASSERT, and seed.

◆ qHash() [13/40]

template<typename Key , typename T >
size_t qHash ( const QSslCertificate key,
size_t  seed 
)
related

Returns the hash value for the key, using seed to seed the calculation.

Since
5.4

Definition at line 962 of file qsslcertificate.cpp.

References seed.

◆ qHash() [14/40]

template<typename Key , typename T >
size_t qHash ( const QSslError key,
size_t  seed 
)
related

Returns the hash value for the key, using seed to seed the calculation.

Since
5.4

Definition at line 339 of file qsslerror.cpp.

References hash, and seed.

◆ qHash() [15/40]

template<typename Key , typename T >
size_t qHash ( const QString key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 154 of file qhashfunctions.h.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [16/40]

template<typename Key , typename T >
size_t qHash ( const QTypeRevision key,
size_t  seed 
)
related
Since
6.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 730 of file qversionnumber.cpp.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [17/40]

template<typename Key , typename T >
size_t qHash ( const QUrl url,
size_t  seed 
)
related

Returns the hash value for the url.

If specified, seed is used to initialize the hash.

Since
5.0

Definition at line 3672 of file qurl.cpp.

References QUrlPrivate::fragment, QUrlPrivate::host, QUrlPrivate::password, QUrlPrivate::path, QUrlPrivate::port, qHash(), QUrlPrivate::query, QUrlPrivate::scheme, seed, url, and QUrlPrivate::userName.

+ Here is the call graph for this function:

◆ qHash() [18/40]

template<typename Key , typename T >
size_t qHash ( const QVersionNumber key,
size_t  seed 
)
related
Since
5.6

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 533 of file qversionnumber.cpp.

References hash, i, and seed.

◆ qHash() [19/40]

template<typename Key , typename T >
template< typename T1, typename T2 > size_t qHash ( const std::pair< T1, T2 > &  key,
size_t  seed = 0 
)
related
Since
5.7

Returns the hash value for the key, using seed to seed the calculation.

Types T1 and T2 must be supported by qHash().

Definition at line 290 of file qhashfunctions.h.

References qHashMulti(), and seed.

+ Here is the call graph for this function:

◆ qHash() [20/40]

template<typename Key , typename T >
template< class T > size_t qHash ( const T *  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 128 of file qhashfunctions.h.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [21/40]

template<typename Key , typename T >
size_t qHash ( double  key,
size_t  seed 
)
related
Since
5.3

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 1426 of file qhash.cpp.

References QHashPrivate::hash(), murmurhash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [22/40]

template<typename Key , typename T >
size_t qHash ( float  key,
size_t  seed = 0 
)
related
Since
5.3

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 106 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [23/40]

template<typename Key , typename T >
size_t qHash ( int  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 93 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [24/40]

template<typename Key , typename T >
size_t qHash ( long double  key,
size_t  seed 
)
related
Since
5.3

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 1445 of file qhash.cpp.

References QHashPrivate::hash(), murmurhash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [25/40]

template<typename Key , typename T >
size_t qHash ( long  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 97 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [26/40]

template<typename Key , typename T >
size_t qHash ( QDate  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 5703 of file qdatetime.cpp.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [27/40]

template<typename Key , typename T >
size_t qHash ( qint64  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 105 of file qhashfunctions.h.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [28/40]

template<typename Key , typename T >
size_t qHash ( QLatin1StringView  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 979 of file qhash.cpp.

References qHashBits(), and seed.

+ Here is the call graph for this function:

◆ qHash() [29/40]

template<typename Key , typename T >
size_t qHash ( QPoint  key,
size_t  seed = 0 
)
related
Since
6.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 455 of file qpoint.cpp.

References qHashMulti(), and seed.

+ Here is the call graph for this function:

◆ qHash() [30/40]

template<typename Key , typename T >
size_t qHash ( QSslEllipticCurve  curve,
size_t  seed = 0 
)
related
Since
5.5

Returns an hash value for the curve curve, using seed to seed the calculation.

Definition at line 53 of file qsslellipticcurve.h.

◆ qHash() [31/40]

template<typename Key , typename T >
size_t qHash ( QTime  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 5714 of file qdatetime.cpp.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [32/40]

template<typename Key , typename T >
size_t qHash ( quint64  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 99 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [33/40]

template<typename Key , typename T >
size_t qHash ( short  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 89 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [34/40]

template<typename Key , typename T >
size_t qHash ( signed char  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 85 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [35/40]

template<typename Key , typename T >
template< class T > size_t qHash ( std::nullptr_t  key,
size_t  seed = 0 
)
related
Since
6.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 132 of file qhashfunctions.h.

References seed.

◆ qHash() [36/40]

template<typename Key , typename T >
size_t qHash ( uchar  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 83 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [37/40]

template<typename Key , typename T >
size_t qHash ( uint  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 91 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [38/40]

template<typename Key , typename T >
size_t qHash ( ulong  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 95 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [39/40]

template<typename Key , typename T >
size_t qHash ( ushort  key,
size_t  seed = 0 
)
related
Since
5.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 87 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [40/40]

template<typename Key , typename T >
size_t qHash ( wchar_t  key,
size_t  seed = 0 
)
related
Since
6.0

Returns the hash value for the key, using seed to seed the calculation.

Definition at line 118 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHashBits()

template<typename Key , typename T >
size_t qHashBits ( const void p,
size_t  len,
size_t  seed = 0 
)
related
Since
5.4

Returns the hash value for the memory block of size len pointed to by p, using seed to seed the calculation.

Use this function only to implement qHash() for your own custom types. For example, here's how you could implement a qHash() overload for std::vector<int>:

inline size_t qHash(const std::vector<int> &key, size_t seed = 0)
{
if (key.empty())
return seed;
else
return qHashBits(&key.front(), key.size() * sizeof(int), seed);
}
size_t qHashBits(const void *p, size_t len, size_t seed=0)
Definition qhash.cpp:924
size_t qHash(const QUrl &url, size_t seed) noexcept
Returns the hash value for the url.
Definition qurl.cpp:3672
GLuint64 key
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196

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 qHashRange() instead.

It bears repeating that the implementation of qHashBits() - like the qHash() overloads offered by Qt - may change at any time. You {must not} rely on the fact that qHashBits() will give the same results (for the same inputs) across different Qt versions.

See also
qHashRange(), qHashRangeCommutative()

Definition at line 924 of file qhash.cpp.

References murmurhash(), qCpuFeatures(), qCpuHasFeature, QT_POINTER_SIZE, qt_qhash_seed, seed, and siphash().

+ Here is the call graph for this function:

◆ qHashEquals()

template<typename Key , typename T >
template< typename T > bool qHashEquals ( const T &  a,
const T &  b 
)
related
Since
6.0

This method is being used by QHash to compare two keys. Returns true if the keys a and b are considered equal for hashing purposes.

The default implementation returns the result of (a == b). It can be reimplemented for a certain type if the equality operator is not suitable for hashing purposes. This is for example the case if the equality operator uses qFuzzyCompare to compare floating point values.

Definition at line 188 of file qhashfunctions.h.

◆ qHashMulti()

template<typename Key , typename T >
template< typename... T > size_t qHashMulti ( size_t  seed,
const T &...  args 
)
related
Since
6.0

Returns the hash value for the {args}, using seed to seed the calculation, by successively applying qHash() to each element and combining the hash values into a single one.

Note that the order of the arguments is significant. If order does not matter, use qHashMultiCommutative() instead. If you are hashing raw memory, use qHashBits(); if you are hashing a range, use qHashRange().

This function is provided as a convenience to implement qHash() for your own custom types. For example, here's how you could implement a qHash() overload for a class {Employee}:

#ifndef EMPLOYEE_H
#define EMPLOYEE_H
class Employee
{
public:
Employee() {}
Employee(const QString &name, QDate dateOfBirth);
...
private:
QString myName;
QDate myDateOfBirth;
};
inline bool operator==(const Employee &e1, const Employee &e2)
{
return e1.name() == e2.name()
&& e1.dateOfBirth() == e2.dateOfBirth();
}
inline size_t qHash(const Employee &key, size_t seed)
{
return qHashMulti(seed, key.name(), key.dateOfBirth());
}
#endif // EMPLOYEE_H
QString name() const
[5] //! [6]
Definition employee.h:49
\inmodule QtCore \reentrant
Definition qdatetime.h:27
QTypeTraits::compare_eq_result_container< QHash, AKey, AT > operator==(const QHash &other) const noexcept
Returns true if other is equal to this hash; otherwise returns false.
Definition qhash.h:902
template< typename... T > size_t qHashMulti(size_t seed, const T &...args)
GLuint name
See also
qHashMultiCommutative, qHashRange

Definition at line 247 of file qhashfunctions.h.

References args, hash, and seed.

◆ qHashMultiCommutative()

template<typename Key , typename T >
template< typename... T > size_t qHashMultiCommutative ( size_t  seed,
const T &...  args 
)
related
Since
6.0

Returns the hash value for the {args}, using seed to seed the calculation, by successively applying qHash() to each element and combining the hash values into a single one.

The order of the arguments is insignificant. If order does matter, use qHashMulti() instead, as it may produce better quality hashing. If you are hashing raw memory, use qHashBits(); if you are hashing a range, use qHashRange().

This function is provided as a convenience to implement qHash() for your own custom types.

See also
qHashMulti, qHashRange

Definition at line 261 of file qhashfunctions.h.

References args, hash, and seed.

◆ qHashRange()

template<typename Key , typename T >
template< typename InputIterator > size_t qHashRange ( InputIterator  first,
InputIterator  last,
size_t  seed = 0 
)
related
Since
5.5

Returns the hash value for the range [{first},{last}), using seed to seed the calculation, by successively applying qHash() to each element and combining the hash values into a single one.

The return value of this function depends on the order of elements in the range. That means that

{0, 1, 2}

and

{1, 2, 0}

hash to {different} values. If order does not matter, for example for hash tables, use qHashRangeCommutative() instead. If you are hashing raw memory, use qHashBits().

Use this function only to implement qHash() for your own custom types. For example, here's how you could implement a qHash() overload for std::vector<int>:

inline size_t qHash(const std::vector<int> &key, size_t seed = 0)
{
return qHashRange(key.begin(), key.end(), seed);
}
template< typename InputIterator > size_t qHashRange(InputIterator first, InputIterator last, size_t seed=0)

It bears repeating that the implementation of qHashRange() - like the qHash() overloads offered by Qt - may change at any time. You {must not} rely on the fact that qHashRange() will give the same results (for the same inputs) across different Qt versions, even if qHash() for the element type would.

See also
qHashBits(), qHashRangeCommutative()

Definition at line 269 of file qhashfunctions.h.

References seed.

◆ qHashRangeCommutative()

template<typename Key , typename T >
template< typename InputIterator > size_t qHashRangeCommutative ( InputIterator  first,
InputIterator  last,
size_t  seed = 0 
)
related
Since
5.5

Returns the hash value for the range [{first},{last}), using seed to seed the calculation, by successively applying qHash() to each element and combining the hash values into a single one.

The return value of this function does not depend on the order of elements in the range. That means that

{0, 1, 2}

and

{1, 2, 0}

hash to the {same} values. If order matters, for example, for vectors and arrays, use qHashRange() instead. If you are hashing raw memory, use qHashBits().

Use this function only to implement qHash() for your own custom types. For example, here's how you could implement a qHash() overload for std::unordered_set<int>:

inline size_t qHash(const std::unordered_set<int> &key, size_t seed = 0)
{
return qHashRangeCommutative(key.begin(), key.end(), seed);
}
template< typename InputIterator > size_t qHashRangeCommutative(InputIterator first, InputIterator last, size_t seed=0)

It bears repeating that the implementation of qHashRangeCommutative() - like the qHash() overloads offered by Qt

  • may change at any time. You {must not} rely on the fact that qHashRangeCommutative() will give the same results (for the same inputs) across different Qt versions, even if qHash() for the element type would.
See also
qHashBits(), qHashRange()

Definition at line 276 of file qhashfunctions.h.

References seed.

◆ QMultiHash< Key, T >

template<typename Key , typename T >
friend class QMultiHash< Key, T >
friend

Definition at line 808 of file qhash.h.

◆ QSet< Key >

template<typename Key , typename T >
friend class QSet< Key >
friend

Definition at line 808 of file qhash.h.


The documentation for this class was generated from the following files: