Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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)
 
std::pair< iterator, iteratorequal_range (const Key &key)
 
std::pair< 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 (quint128 key, size_t seed=0)
 
size_t qHash (qint128 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)
 
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 QTypeRevision &key, size_t seed)
 
size_t qHash (const QVersionNumber &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:

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():

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");

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

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
QHash<int, QWidget *> hash;
...
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;
}

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;

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:

QHash<QString, int> hash;
...
for (int value : std::as_const(hash))
cout << value << endl;

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 819 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 1208 of file qhash.h.

◆ const_reference

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

Definition at line 836 of file qhash.h.

◆ ConstIterator

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

Qt-style synonym for QHash::const_iterator.

Definition at line 1289 of file qhash.h.

◆ difference_type

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

Typedef for ptrdiff_t.

Provided for STL compatibility.

Definition at line 834 of file qhash.h.

◆ Iterator

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

Qt-style synonym for QHash::iterator.

Definition at line 1288 of file qhash.h.

◆ key_type

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

Typedef for Key.

Provided for STL compatibility.

Definition at line 830 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 1209 of file qhash.h.

◆ mapped_type

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

Typedef for T.

Provided for STL compatibility.

Definition at line 831 of file qhash.h.

◆ reference

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

Definition at line 835 of file qhash.h.

◆ size_type

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

Typedef for int.

Provided for STL compatibility.

Definition at line 833 of file qhash.h.

◆ value_type

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

Definition at line 832 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()

◆ 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 839 of file qhash.h.

References QList< T >::begin(), QHash< Key, T >::const_iterator, 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 845 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 851 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 873 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 {std::pair}), 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 883 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 892 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 1228 of file qhash.h.

References QtPrivate::QKeyValueRange().

Referenced by QNetworkRequestFactoryPrivate::newRequest().

+ Here is the call graph for this function:
+ 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 1230 of file qhash.h.

References QtPrivate::QKeyValueRange().

+ Here is the call graph for this function:

◆ asKeyValueRange() [3/4]

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

Definition at line 1229 of file qhash.h.

References QtPrivate::QKeyValueRange().

+ Here is the call graph for this function:

◆ asKeyValueRange() [4/4]

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

Definition at line 1231 of file qhash.h.

References QtPrivate::QKeyValueRange().

+ Here is the call graph for this function:

◆ 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.

qhash-iterator-invalidation-func-desc

See also
constBegin(), end()

Definition at line 1212 of file qhash.h.

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

Referenced by QQuickDesignerSupport::~QQuickDesignerSupport(), QQuickSmoothedAnimationPrivate::~QQuickSmoothedAnimationPrivate(), QQuickTimeLine::~QQuickTimeLine(), QWindowsDirectWriteFontDatabase::~QWindowsDirectWriteFontDatabase(), QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(), QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QFseventsFileSystemWatcherEngine::addPaths(), QQuickTimeLinePrivate::advance(), QSet< T >::begin(), QV4::MultiplyWrappedQObjectMap::begin(), QSet< T >::begin(), QV4DebuggerAgent::breakPointIds(), QGraphicsScenePrivate::cancelGesturesForChildren(), QSet< T >::cbegin(), QWaylandTextureSharingExtension::cleanupBuffers(), QSSGRhiContextPrivate::cleanupDrawCallData(), QQmlTypeLoader::clearCache(), QAbstractItemViewPrivate::columnsAboutToBeRemoved(), QHash< Key, T >::constKeyValueBegin(), QD3D11Buffer::destroy(), QGraphicsScenePrivate::gestureEventHandler(), QHttp2Connection::handleConnectionClosure(), 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(), QSvgIconEngine::read(), readDependencies(), QGraphicsScenePrivate::removeItemHelper(), QAndroidPlatformMenuBar::removeMenu(), QAndroidPlatformMenu::removeMenuItem(), QQuickWorkerScriptEngine::run(), QPollingFileSystemWatcherEngine::timerEvent(), QSocks5BindStore::timerEvent(), QQmlTypeLoader::trimCache(), QQuickSpringAnimationPrivate::updateMode(), QQuickItemViewPrivate::updateUnrequestedIndexes(), VDMAbstractItemModelDataType::value(), and QHash< Key, T >::values().

+ Here is the call graph for this function:
+ Here is the caller 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.

qhash-iterator-invalidation-func-desc

Definition at line 1213 of file qhash.h.

References QHash< Key, T >::const_iterator, and d.

◆ bucket_count()

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

Definition at line 1346 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 930 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.

qhash-iterator-invalidation-func-desc

See also
begin(), cend()

Definition at line 1214 of file qhash.h.

References QHash< Key, T >::const_iterator, and d.

Referenced by QGestureManager::~QGestureManager(), QItemEditorFactory::~QItemEditorFactory(), QRhiImplementation::~QRhiImplementation(), QSmoothedAnimation::~QSmoothedAnimation(), QSpringAnimation::~QSpringAnimation(), QtFreetypeData::~QtFreetypeData(), QQuickTimeLine::clear(), QWindowsContext::findPlatformWindow(), QHttp2Connection::handleReadyRead(), QItemEditorFactory::registerEditor(), QQmlJSCodeGenerator::run(), QRhi::runCleanup(), 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.

qhash-iterator-invalidation-func-desc

See also
cbegin(), end()

Definition at line 1218 of file qhash.h.

References QHash< Key, T >::const_iterator.

Referenced by QGestureManager::~QGestureManager(), QItemEditorFactory::~QItemEditorFactory(), QRhiImplementation::~QRhiImplementation(), QSmoothedAnimation::~QSmoothedAnimation(), QSpringAnimation::~QSpringAnimation(), QtFreetypeData::~QtFreetypeData(), QNetworkReplyHttpImplPrivate::_q_metaDataChanged(), QWidgetAnimator::abort(), Graph< Vertex, EdgeData >::adjacentVertices(), QCommandLineParserPrivate::aliases(), QSSGRhiShaderPipeline::bindingForTexture(), QQuickTimeLine::clear(), QSGRhiAtlasTexture::Manager::create(), Graph< Vertex, EdgeData >::edgeData(), QQuickWorkerScriptEnginePrivate::event(), QWindowsContext::findPlatformWindow(), QSSGLayerRenderData::getBonemapTexture(), QSSGShaderLibraryManager::getIncludeContents(), QSSGLayerRenderData::getLightmapTexture(), QSSGShaderLibraryManager::getShaderMetaData(), QSSGShaderLibraryManager::getShaderSource(), QFontEngine::glyphCache(), QAndroidActivityResultReceiverPrivate::handleActivityResult(), QHttp2Connection::handleReadyRead(), QNetworkReplyImplPrivate::metaDataChanged(), QPMCache::object(), QSSGRhiShaderPipeline::offsetOfUniform(), QSGMaterialShaderPrivate::prepare(), QItemEditorFactory::registerEditor(), QAbstractItemViewPrivate::removeEditor(), QQmlComponentPrivate::removePropertyFromRequired(), QQuickWorkerScriptEngine::removeWorkerScript(), QSocks5BindStore::retrieve(), QQmlJSCodeGenerator::run(), QRhi::runCleanup(), QSSGRhiShaderPipeline::setUniform(), QSSGRhiShaderPipeline::setUniformArray(), QQmlOpenMetaObject::setValue(), QQmlDMAbstractItemModelData::setValue(), QSSGShaderCache::tryGetRhiShaderPipeline(), QGestureManager::unregisterGestureRecognizer(), 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 951 of file qhash.h.

References d.

Referenced by LinuxDmabufClientBufferIntegration::~LinuxDmabufClientBufferIntegration(), QOpenGLContextVersionData::~QOpenGLContextVersionData(), QQmlMetaTypeData::~QQmlMetaTypeData(), QQuickCanvasItemPrivate::~QQuickCanvasItemPrivate(), QQuickPixmapReader::~QQuickPixmapReader(), QtFreetypeData::~QtFreetypeData(), QOpenGLContextGroupPrivate::cleanup(), QMimeAllGlobPatterns::clear(), QMimeTypeXMLData::clear(), QSet< T >::clear(), QFontCache::clear(), QNetworkAccessCache::clear(), QHeaderViewPrivate::clear(), QQuickParticleDataHeap::clear(), QQuickTimeLine::clear(), QNetworkRequestFactory::clearAttributes(), QQmlTypeLoader::clearCache(), QQmlJSImporter::clearCache(), QHeaderViewPrivate::clearCascadingSections(), QRelation::clearDictionary(), QFont::clearFeatures(), QNetworkHeadersPrivate::clearHeaders(), QRhiGles2::compileShader(), QD3D11Buffer::destroy(), QRhiGles2::destroy(), QRhiMetal::destroy(), QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations(), QLowEnergyControllerPrivateBluezDBus::discoverServiceDetails(), QQmlTypeData::done(), QMimeXMLProvider::ensureLoaded(), QNetworkReplyHttpImplPrivate::followRedirect(), QGraphicsScenePrivate::gestureEventHandler(), QQmlJSTypeResolver::init(), QSGRhiAtlasTexture::Manager::invalidate(), QCoreTextFontDatabase::invalidate(), QSGSoftwareRenderContext::invalidate(), QSGDefaultRenderContext::invalidate(), QSGDefaultRenderContext::invalidateGlyphCaches(), QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson(), QPpdPrintDevice::loadPageSizes(), QCocoaPrintDevice::loadPageSizes(), QCommandLineParserPrivate::parse(), QCoreTextFontDatabase::populateFontDatabase(), QSvgIconEngine::read(), QSSGShaderCache::releaseCachedResources(), QSSGRhiContextPrivate::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(), QRhi::runCleanup(), QQuickImageParticle::sceneGraphInvalidated(), QHeaderViewPrivate::sectionsChanged(), 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.

qhash-iterator-invalidation-func-desc

See also
begin(), constEnd()

Definition at line 1215 of file qhash.h.

References QHash< Key, T >::const_iterator, and d.

Referenced by 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(), QMacPrintEnginePrivate::initialize(), VDMAbstractItemModelDataType::initializeConstructor(), QSGDefaultRenderContext::invalidate(), QSimplexConstraint::isSatisfied(), QQmlJSCodeGenerator::lookupVariable(), main(), QAndroidPlatformMenuBar::menuId(), QAndroidPlatformMenu::menuId(), QFont::operator<(), readInputFile(), readInputFileDirectory(), QGeoTiledMappingManagerEngine::releaseMap(), ThreadedTestHTTPServer::run(), QXcbConnection::startSystemMoveResizeForTouch(), QQmlSettingsPrivate::store(), 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.

qhash-iterator-invalidation-func-desc

See also
constBegin(), end()

Definition at line 1219 of file qhash.h.

References QHash< Key, T >::const_iterator.

Referenced by QCocoaCursor::~QCocoaCursor(), QQuickWanderAffector::~QQuickWanderAffector(), QMimeXMLProvider::addAllMimeTypes(), QGraphicsScenePrivate::addView(), QQuickTimeLinePrivate::advance(), QWidgetAnimator::animate(), QMetaStringTable::blobSize(), buildAndroidProject(), QOpenGLContextGroupPrivate::cleanup(), QQmlTypeCompiler::compile(), QRhiGles2::compileShader(), QSSGRhiContextPrivate::computePipeline(), QSet< T >::constEnd(), QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations(), QQmlOpenMetaObject::emitPropertyNotification(), QV4::MultiplyWrappedQObjectMap::end(), QHash< Key, T >::erase(), QQmlMetaTypeData::findPropertyCacheInCompositeTypes(), QQmlDebugServerImpl::hasEngine(), QWindowsCursor::hCursor(), QMacPrintEnginePrivate::initialize(), VDMAbstractItemModelDataType::initializeConstructor(), QQmlTypeLoader::injectedScript(), QSGDefaultRenderContext::invalidate(), QSimplexConstraint::isSatisfied(), QQmlPreviewFileLoader::load(), Cache::lookup(), QQmlJSCodeGenerator::lookupVariable(), main(), QAndroidPlatformMenuBar::menuId(), QAndroidPlatformMenu::menuId(), QDesktopServices::openUrl(), QFont::operator<(), QCommandLineParserPrivate::parse(), QCommandLineParserPrivate::parseOptionValue(), QSSGRhiContextPrivate::pipeline(), QQuickShaderEffectPrivate::propertyChanged(), readInputFile(), readInputFileDirectory(), QQmlMetaTypeData::registerModuleTypes(), QQmlJSCodeGenerator::registerVariable(), QGeoTiledMappingManagerEngine::releaseMap(), QXcbEventQueue::removePeekerId(), QQmlProfilerClientPrivate::resolveType(), QtWaylandClient::QWaylandMimeData::retrieveData_sys(), ThreadedTestHTTPServer::run(), QSSGRhiShaderPipeline::setUniform(), QSSGRhiShaderPipeline::setUniformArray(), QSSGRhiContextPrivate::srb(), QQmlJSCodeGenerator::startInstruction(), QXcbConnection::startSystemMoveResizeForTouch(), QQmlSettingsPrivate::store(), QBackingStoreRhiSupport::swapChainForWindow(), 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().

qhash-iterator-invalidation-func-desc

See also
find()

Definition at line 1299 of file qhash.h.

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

Referenced by QSmoothedAnimation::~QSmoothedAnimation(), QSpringAnimation::~QSpringAnimation(), QNetworkReplyHttpImplPrivate::_q_metaDataChanged(), QWidgetAnimator::abort(), Graph< Vertex, EdgeData >::adjacentVertices(), QCommandLineParserPrivate::aliases(), QWidgetAnimator::animate(), QSSGRhiShaderPipeline::bindingForTexture(), QRhiGles2::compileShader(), QSSGRhiContextPrivate::computePipeline(), Graph< Vertex, EdgeData >::edgeData(), QQmlOpenMetaObject::emitPropertyNotification(), QQuickWorkerScriptEnginePrivate::event(), QQmlMetaType::findCompositeType(), QQmlMetaTypeData::findPropertyCacheInCompositeTypes(), QSSGLayerRenderData::getBonemapTexture(), QSSGShaderLibraryManager::getIncludeContents(), QSSGLayerRenderData::getLightmapTexture(), QSSGShaderLibraryManager::getShaderMetaData(), QSSGShaderLibraryManager::getShaderSource(), QFontEngine::glyphCache(), QQmlDebugServerImpl::hasEngine(), QWindowsCursor::hCursor(), QQmlTypeLoader::injectedScript(), QQmlPreviewFileLoader::load(), Cache::lookup(), QNetworkReplyImplPrivate::metaDataChanged(), QQmlMetaType::obtainCompilationUnit(), QSSGRhiShaderPipeline::offsetOfUniform(), QDesktopServices::openUrl(), QCommandLineParserPrivate::parse(), QCommandLineParserPrivate::parseOptionValue(), QSSGRhiContextPrivate::pipeline(), QSGMaterialShaderPrivate::prepare(), QQuickShaderEffectPrivate::propertyChanged(), QItemEditorFactory::registerEditor(), QQmlMetaTypeData::registerModuleTypes(), QQmlJSCodeGenerator::registerVariable(), QAbstractItemViewPrivate::removeEditor(), QXcbEventQueue::removePeekerId(), QQmlComponentPrivate::removePropertyFromRequired(), QQuickWorkerScriptEngine::removeWorkerScript(), QQmlProfilerClientPrivate::resolveType(), QSocks5BindStore::retrieve(), QtWaylandClient::QWaylandMimeData::retrieveData_sys(), QSSGRhiShaderPipeline::setUniform(), QSSGRhiShaderPipeline::setUniformArray(), QQmlOpenMetaObject::setValue(), QQmlDMAbstractItemModelData::setValue(), QQmlOpenMetaObject::setValues(), QSSGRhiContextPrivate::srb(), QQmlJSCodeGenerator::startInstruction(), QBackingStoreRhiSupport::swapChainForWindow(), QOpenXRView::touchpointState(), QSSGShaderCache::tryGetRhiShaderPipeline(), QGestureManager::unregisterGestureRecognizer(), 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.

qhash-iterator-invalidation-func-desc

See also
keyValueBegin()

Definition at line 1225 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.

qhash-iterator-invalidation-func-desc

See also
constKeyValueBegin()

Definition at line 1227 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()

Definition at line 1007 of file qhash.h.

References d.

Referenced by QSocks5BindStore::add(), QQmlDebugServerImpl::addEngine(), QSvgTinyDocument::addNamedStyle(), QCommandLineParser::addOption(), QFseventsFileSystemWatcherEngine::addPaths(), QQmlDebugServerImpl::addService(), QGeoTiledMapScenePrivate::addTile(), QGeoPositionInfo::attribute(), QGeoSatelliteInfo::attribute(), QHeaderViewPrivate::cascadingResize(), QHaikuCursor::changeCursor(), Moc::checkSuperClasses(), QNetworkRequestFactory::clearAttribute(), QSet< T >::contains(), QSocks5BindStore::contains(), QColorOutputPrivate::containsColor(), QHash< Key, T >::count(), QQuickPath::createPath(), CustomDataProxy::data(), QGraphicsItem::data(), QQmlJSAnnotation::deprecation(), QLowEnergyControllerPrivateBluezDBus::discoverServiceDetails(), QQmlTableInstanceModel::dispose(), QSvgFont::draw(), QGestureManager::filterEvent(), QGraphicsScenePrivate::gestureEventHandler(), goodToCopy(), QSGSoftwareRenderLoop::grab(), QDialogButtonBoxPrivate::handleButtonShowAndHide(), QGeoPositionInfo::hasAttribute(), QGeoSatelliteInfo::hasAttribute(), QAbstractItemViewPrivate::hasEditor(), QNetworkAccessCache::hasEntry(), LinuxDmabufClientBufferIntegration::importBuffer(), QDeclarativeSupportedCategoriesModel::index(), QQuickParticleDataHeap::insertTimed(), BluetoothManagement::isAddressRandom(), QQuickPixmap::isCached(), QFont::isFeatureSet(), QQmlTypeLoader::isScriptLoaded(), QQmlToolingSettings::isSet(), QQmlTypeLoader::isTypeLoaded(), QWaylandIviApplicationPrivate::ivi_application_surface_create(), QMimeXMLProvider::knowsMimeType(), QSGRhiShaderLinker::linkTextureSubRects(), QQuickTableViewPrivate::loadedTableItem(), QCocoaPrintDevice::macPaper(), Moc::parseClassHead(), QSGCurveGlyphAtlas::populate(), QSGOpenVGFontGlyphCache::populate(), QWindowsDirectWriteFontDatabase::populateFamilyAliases(), QPpdPrintDevice::printableMargins(), QCocoaPrintDevice::printableMargins(), QQuickShaderEffectPrivate::propertyChanged(), readInputFile(), readInputFileDirectory(), QQuickDesignerSupport::refFromEffectItem(), QCommandLineParserPrivate::registerFoundOption(), QCtfLibImpl::registerMetadata(), QQuickParticleSystem::registerParticleGroupData(), QWaylandXdgOutputManagerV1Private::registerXdgOutput(), QQmlTableInstanceModel::release(), QQmlDebugServerImpl::removeEngine(), QQmlWatcher::removeWatch(), 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(), QQmlJSImportVisitor::visit(), QTextOdfWriter::writeAll(), QTextOdfWriter::writeFrame(), 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 1290 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 1013 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 947 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(), and QHash< Key, T >::insert().

+ 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 1324 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.

qhash-iterator-invalidation-func-desc

Definition at line 1331 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 1349 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.

qhash-iterator-invalidation-func-desc

Definition at line 1217 of file qhash.h.

References QHash< Key, T >::const_iterator.

◆ 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.

qhash-iterator-invalidation-func-desc

See also
begin(), constEnd()

Definition at line 1216 of file qhash.h.

References QHash< Key, T >::iterator.

Referenced by QQuickDesignerSupport::~QQuickDesignerSupport(), QQuickSmoothedAnimationPrivate::~QQuickSmoothedAnimationPrivate(), QQuickTimeLine::~QQuickTimeLine(), QWindowsDirectWriteFontDatabase::~QWindowsDirectWriteFontDatabase(), QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(), QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QQuickTimeLinePrivate::add(), QFseventsFileSystemWatcherEngine::addPaths(), QQuickTimeLinePrivate::advance(), QV4DebuggerAgent::breakPointIds(), QGeoTiledMapScenePrivate::buildGeometry(), QGraphicsScenePrivate::cancelGesturesForChildren(), QSet< T >::cend(), QXcbCursor::changeCursor(), QWaylandTextureSharingExtension::cleanupBuffers(), QSSGRhiContextPrivate::cleanupDrawCallData(), QQmlTypeLoader::clearCache(), QAbstractItemViewPrivate::columnsAboutToBeRemoved(), QHash< Key, T >::constKeyValueEnd(), LinuxDmabufClientBufferIntegration::createBufferFor(), QD3D11Buffer::destroy(), QAndroidStyle::drawComplexControl(), QAndroidStyle::drawControl(), QAndroidStyle::drawPrimitive(), QAbstractItemViewPrivate::editorForIndex(), QSet< T >::end(), QV4::MultiplyWrappedQObjectMap::end(), QSet< T >::end(), QMetaStringTable::enter(), QGraphicsScenePrivate::gestureEventHandler(), QTest::TestRegistry::getTestEntryFunction(), QHttp2Connection::handleConnectionClosure(), 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(), QEventDispatcherUNIXPrivate::markPendingSocketNotifiers(), VDMAbstractItemModelDataType::notify(), QHash< Key, T >::operator==(), QXcbEventQueue::peekEventQueue(), QWindowsCursor::pixmapWindowCursor(), QWindowsDirectWriteFontDatabase::populateFamily(), QFseventsFileSystemWatcherEngine::processEvent(), QSvgIconEngine::read(), readDependencies(), Graph< Vertex, EdgeData >::removeDirectedEdge(), QGraphicsScenePrivate::removeItemHelper(), QAndroidPlatformMenuBar::removeMenu(), QAndroidPlatformMenu::removeMenuItem(), QFseventsFileSystemWatcherEngine::removePaths(), QWindowsContext::removeWindow(), Preprocessor::resolveInclude(), QQuickWorkerScriptEngine::run(), QSSGShaderLibraryManager::setShaderSource(), QQmlTableModelColumn::setterAtRole(), QSSGCustomMaterialSystem::shadersForCustomMaterial(), QAndroidStyle::sizeFromContents(), QWindowsCursor::standardWindowCursor(), QAndroidStyle::subControlRect(), QAndroidStyle::subElementRect(), QQuickTimeLine::sync(), QQuickTimeLine::sync(), QPollingFileSystemWatcherEngine::timerEvent(), 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 >
std::pair< iterator, iterator > QHash< Key, T >::equal_range ( const Key & key)
inline

Definition at line 1247 of file qhash.h.

◆ equal_range() [2/2]

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

Definition at line 1251 of file qhash.h.

◆ 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> objectHash;
...
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;
}
}

qhash-iterator-invalidation-func-desc

See also
remove(), take(), find()

Definition at line 1233 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(), QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(), QWidgetAnimator::abort(), QQuickTimeLinePrivate::advance(), QWaylandTextureSharingExtension::cleanupBuffers(), QSSGRhiContextPrivate::cleanupDrawCallData(), QAbstractItemViewPrivate::columnsAboutToBeRemoved(), QSet< T >::erase(), QV4::MultiplyWrappedQObjectMap::erase(), QQuickWorkerScriptEnginePrivate::event(), QSGDefaultRenderContext::invalidateGlyphCaches(), QWindowsCursor::pixmapWindowCursor(), QSGMaterialShaderPrivate::prepare(), QQuickShaderEffectPrivate::propertyChanged(), readDependencies(), QItemEditorFactory::registerEditor(), Graph< Vertex, EdgeData >::removeDirectedEdge(), QAbstractItemViewPrivate::removeEditor(), QGraphicsScenePrivate::removeItemHelper(), QAndroidPlatformMenuBar::removeMenu(), QAndroidPlatformMenu::removeMenuItem(), QFseventsFileSystemWatcherEngine::removePaths(), QXcbEventQueue::removePeekerId(), QQmlComponentPrivate::removePropertyFromRequired(), QWindowsContext::removeWindow(), QSocks5BindStore::retrieve(), QPollingFileSystemWatcherEngine::timerEvent(), QSocks5BindStore::timerEvent(), QQmlTypeLoader::trimCache(), and QGestureManager::unregisterGestureRecognizer().

+ 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> hash;
...
QHash<QString, int>::const_iterator i = hash.find("HDR");
while (i != hash.end() && i.key() == "HDR") {
cout << i.value() << endl;
++i;
}

qhash-iterator-invalidation-func-desc

See also
value(), values()

Definition at line 1291 of file qhash.h.

Referenced by QQuickTimeLinePrivate::add(), QFseventsFileSystemWatcherEngine::addPaths(), QGeoTiledMapScenePrivate::buildGeometry(), QXcbCursor::changeCursor(), QHash< Key, T >::constFind(), QSGRhiAtlasTexture::Manager::create(), LinuxDmabufClientBufferIntegration::createBufferFor(), QAndroidStyle::drawComplexControl(), QAndroidStyle::drawControl(), QAndroidStyle::drawPrimitive(), QAbstractItemViewPrivate::editorForIndex(), QMetaStringTable::enter(), QSet< T >::find(), QSet< T >::find(), QTest::TestRegistry::getTestEntryFunction(), QAndroidStyle::hitTestComplexControl(), QAbstractItemViewPrivate::indexForEditor(), QCtfLibImpl::initializeTracepoint(), QQuickPixmap::load(), QQuickPixmap::loadImageFromDevice(), QEventDispatcherUNIXPrivate::markPendingSocketNotifiers(), VDMAbstractItemModelDataType::notify(), QPMCache::object(), QHash< Key, T >::operator==(), QXcbEventQueue::peekEventQueue(), QWindowsCursor::pixmapWindowCursor(), QWindowsDirectWriteFontDatabase::populateFamily(), QFseventsFileSystemWatcherEngine::processEvent(), Graph< Vertex, EdgeData >::removeDirectedEdge(), QFseventsFileSystemWatcherEngine::removePaths(), QWindowsContext::removeWindow(), Preprocessor::resolveInclude(), QSSGShaderLibraryManager::setShaderSource(), QQmlTableModelColumn::setterAtRole(), QSSGCustomMaterialSystem::shadersForCustomMaterial(), QAndroidStyle::sizeFromContents(), QWindowsCursor::standardWindowCursor(), QAndroidStyle::subControlRect(), QAndroidStyle::subElementRect(), QQuickTimeLine::sync(), QQuickTimeLine::sync(), QD3D11Buffer::unorderedAccessView(), VDMAbstractItemModelDataType::value(), and QQuickWorkerScriptEnginePrivate::workerEngine().

+ Here is the caller 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.

qhash-iterator-invalidation-func-desc

Definition at line 1295 of file qhash.h.

◆ 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.

Returns an iterator pointing to the new/updated element.

qhash-iterator-invalidation-func-desc

Definition at line 1303 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(), Python::WriteImports::WriteImports(), QQmlSettingsPrivate::_q_propertyChanged(), QSocks5BindStore::add(), QQuickTimeLinePrivate::add(), QMimeXMLProvider::addAlias(), TestHTTPServer::addAlias(), QV4DebuggerAgent::addBreakPoint(), QPdfEnginePrivate::addConstantAlphaObject(), QAbstractItemViewPrivate::addEditor(), QNetworkAccessCache::addEntry(), QSvgIconEngine::addFile(), QSvgFont::addGlyph(), QPdfEnginePrivate::addImage(), QMimeXMLProvider::addMimeType(), QSvgTinyDocument::addNamedNode(), QSvgTinyDocument::addNamedStyle(), QSGAbstractSoftwareRenderer::addNodeMapping(), QCommandLineParser::addOption(), QFseventsFileSystemWatcherEngine::addPaths(), 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(), QQmlTypeCompiler::compile(), QSSGShaderCache::compileForRhi(), QRhiGles2::compileShader(), QSSGRhiContextPrivate::computePipeline(), QV4::ExecutionEngine::consoleCountHelper(), QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints(), QSGRhiAtlasTexture::Manager::create(), QDialogButtonBoxPrivate::createButton(), QWasmIntegration::createPlatformBackingStore(), QQmlOpenMetaObjectType::createProperties(), QQmlOpenMetaObjectType::createProperty(), createSlack(), QSGDefaultRenderContext::curveGlyphAtlas(), QLowEnergyControllerPrivateBluezDBus::discoverServices(), QCtfLibImpl::doTracepoint(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QGraphicsScenePrivate::drawSubtreeRecursive(), QPdfEnginePrivate::drawTextItem(), QMetaStringTable::enter(), QSGRhiShaderLinker::feedSamplers(), QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QXcbEventQueue::generatePeekerId(), QGraphicsScenePrivate::gestureEventHandler(), QSSGShaderLibraryManager::getIncludeContents(), QQmlTypeLoader::getQmldir(), QQmlTypeLoader::getScript(), QSSGAssetImportManager::getSupportedExtensions(), QQmlTypeLoader::getType(), QDialogButtonBoxPrivate::handleButtonShowAndHide(), QQmlJSImporter::importQmldirs(), QLowEnergyControllerPrivateBluez::init(), QNetworkReplyHttpImplPrivate::initCacheSaveDevice(), QNetworkReplyImplPrivate::initCacheSaveDevice(), QPlaceManagerEngineNokiaV2::initializeCategories(), VDMAbstractItemModelDataType::initializeMetaType(), QCtfLibImpl::initializeTracepoint(), QQmlTypeLoader::injectScript(), QSet< T >::insert(), QSGOpenVGFontGlyphCacheManager::insertCache(), QColorOutputPrivate::insertColor(), QAndroidPlatformMenuBar::insertMenu(), QDBusPlatformMenu::insertMenuItem(), QAndroidPlatformMenu::insertMenuItem(), QQuickParticleDataHeap::insertTimed(), QWaylandIviApplicationPrivate::ivi_application_surface_create(), QDefaultOutputMapping::load(), QPpdPrintDevice::loadPageSizes(), QCocoaPrintDevice::loadPageSizes(), QCocoaPrintDevice::macPaper(), QSSGShaderCache::newPipelineFromPregenerated(), QWinRTLowEnergyServiceHandler::obtainCharList(), Moc::parse(), Moc::parseClassHead(), QSSGRhiContextPrivate::pipeline(), QWindowsCursor::pixmapWindowCursor(), QSGCurveGlyphAtlas::populate(), QWindowsDirectWriteFontDatabase::populateFontDatabase(), QQuickTableViewPrivate::processLoadRequest(), QQmlMetaTypeData::propertyCache(), QQuickShaderEffectPrivate::propertyChanged(), QSvgIconEngine::read(), readAndroidDependencyXml(), readInputFile(), SharedTextureRegistry::receiveBuffer(), QNetworkReplyImplPrivate::redirectionRequested(), QQuickDesignerSupport::refFromEffectItem(), QCtfLibImpl::registerMetadata(), QQuickParticleSystem::registerParticleGroupData(), QCFSocketNotifier::registerSocketNotifier(), QQuickWorkerScriptEngine::registerWorkerScript(), QQuickItemViewPrivate::releaseItem(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QGeoAreaMonitorPollingPrivate::requestUpdate(), Preprocessor::resolveInclude(), QtWaylandClient::QWaylandMimeData::retrieveData_sys(), QQmlListModel::roleNames(), QQmlXmlListModel::roleNames(), QDeclarativeGeocodeModel::roleNames(), QDeclarativeGeoRouteModel::roleNames(), QDeclarativeSearchSuggestionModel::roleNames(), QQmlJSCodeGenerator::run(), QHeaderViewPrivate::saveCascadingSectionSize(), QNetworkRequest::setAttribute(), QNetworkRequestFactory::setAttribute(), QmlLsp::QQmlCodeModel::setBuildPathsForRootUrl(), QSimplex::setConstraints(), QCocoaWindow::setContentBorderAreaEnabled(), QNetworkHeadersPrivate::setCookedHeader(), QFontPrivate::setFeature(), QAuthenticator::setOption(), QSSGShaderLibraryManager::setShaderSource(), QDesktopServices::setUrlHandler(), QSSGCustomMaterialSystem::shadersForCustomMaterial(), QGraphicsAnchorLayoutPrivate::solveMinMax(), QGraphicsAnchorLayoutPrivate::solvePreferred(), QSSGRhiContextPrivate::srb(), QWindowsCursor::standardWindowCursor(), QGeoAreaMonitorPollingPrivate::startMonitoring(), QBackingStoreRhiSupport::swapChainForWindow(), QSGRenderContext::textureForFactory(), QGeoTileRequestManagerPrivate::tileError(), QWindowsMouseHandler::translateTouchEvent(), QSSGShaderCache::tryNewPipelineFromPersistentCache(), Driver::unique(), QGestureManager::unregisterGestureRecognizer(), QQuick3DSceneManager::updateDirtyResource(), QQuick3DSceneManager::updateDirtyResourceSecondPass(), QQuick3DSceneManager::updateDirtySpatialNode(), QmlLsp::QQmlCodeModel::url2Path(), QQmlJSImportVisitor::visit(), QTextOdfWriter::writeAll(), QWaylandTextInputPrivate::zwp_text_input_v2_enable(), QWaylandTextInputV3Private::zwp_text_input_v3_bind_resource(), and QWaylandTextInputV3Private::zwp_text_input_v3_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 1308 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 948 of file qhash.h.

References d.

Referenced by QHash< Key, T >::emplace(), QSet< T >::isDetached(), 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 928 of file qhash.h.

References d.

Referenced by QSGRhiAtlasTexture::Manager::~Manager(), QRhiImplementation::~QRhiImplementation(), QHeaderViewPrivate::adjustedVisualIndex(), QWidgetAnimator::animating(), QQuickTableViewPrivate::checkForVisibilityChanges(), QGeoAreaMonitorPollingPrivate::checkStartStop(), QNetworkRequestFactory::clearAttributes(), QFont::clearFeatures(), QAbstractItemViewPrivate::editorForIndex(), QHash< Key, T >::empty(), QAbstractItemViewPrivate::hasEditor(), QQmlIncubatorPrivate::incubateCppBasedComponent(), QAbstractItemViewPrivate::indexForEditor(), PlaceManagerEngineEsri::initializeCategories(), QPlaceManagerEngineMapbox::initializeCategories(), QPlaceManagerEngineOsm::initializeCategories(), QSGSoftwareRenderContext::invalidate(), QQuickTimeLine::isActive(), QSet< T >::isEmpty(), QQuickTableViewPrivate::loadAndUnloadVisibleEdges(), QQuickTableViewPrivate::loadInitialTable(), QFileSystemModelPrivate::name(), QCocoaTheme::palette(), QQuickTableViewPrivate::processRebuildTable(), readDependencies(), QLibInputTouch::registerDevice(), QKqueueFileSystemWatcherEngine::removePaths(), QXcbEventQueue::removePeekerId(), QQmlSettingsPrivate::reset(), QSocks5BindStore::retrieve(), QQuickTableViewPrivate::scrollTowardsSelectionPoint(), QHeaderViewPrivate::sectionsHiddenToBitVector(), QHeaderViewPrivate::setDefaultSectionSize(), QQuickTableViewPrivate::setSelectionEndPos(), QQuickTableViewPrivate::setSelectionStartPos(), QQuickTableViewPrivate::syncRebuildOptions(), QQuickTableViewPrivate::syncSyncView(), QQuickTableViewPrivate::tableLayoutToString(), QQuickTableViewPrivate::updateContentHeight(), QQuickTableViewPrivate::updateContentWidth(), QQuickTimeLine::updateCurrentTime(), QSGDistanceFieldGlyphNode::updateGeometry(), updateLibsXml(), QQuickTableViewPrivate::updateTable(), and QSvgIconEngine::virtual_hook().

+ Here is the caller graph for this function:

◆ 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 949 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 1034 of file qhash.h.

References Key.

Referenced by QQmlTableModel::data(), 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 1038 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.

qhash-iterator-invalidation-func-desc

See also
keyEnd()

Definition at line 1220 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.

qhash-iterator-invalidation-func-desc

See also
keyBegin()

Definition at line 1221 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 1086 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(), QCoreTextFontDatabase::populateFontDatabase(), readInputFile(), readInputFileDirectory(), and QDeclarativeSupportedCategoriesModel::rowCount().

+ 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 1087 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.

qhash-iterator-invalidation-func-desc

See also
keyValueEnd()

Definition at line 1222 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.

qhash-iterator-invalidation-func-desc

See also
keyValueEnd()

Definition at line 1224 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.

qhash-iterator-invalidation-func-desc

See also
keyValueBegin()

Definition at line 1223 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.

qhash-iterator-invalidation-func-desc

See also
keyValueBegin()

Definition at line 1226 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 1344 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 1347 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 1345 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 920 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 860 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 904 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.

! [qhash-iterator-invalidation-func-desc]

Warning
Returned iterators/references should be considered invalidated the next time you call a non-const function on the hash, or when the hash is destroyed. ! [qhash-iterator-invalidation-func-desc]
\sa insert(), value()

Definition at line 1064 of file qhash.h.

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

+ 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 1081 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 958 of file qhash.h.

Referenced by SharedTextureRegistry::abandonBuffer(), QQuickAnimatorController::animationFinished(), QParallelAnimationGroupPrivate::animationRemoved(), QtWaylandClient::QWaylandMimeData::appendFormat(), QQuickAnimatorController::beforeNodeSync(), QQmlTableInstanceModel::cancel(), QGraphicsScenePrivate::cancelGesturesForChildren(), QHeaderViewPrivate::cascadingResize(), QGestureManager::cleanupCachedGestures(), QQuick3DSceneManager::cleanupNodes(), QNetworkRequestFactory::clearAttribute(), QFontEngine::clearGlyphCache(), QQuickItemViewPrivate::createItem(), QQmlTableInstanceModel::dispose(), QGestureManager::filterEventThroughContexts(), QGraphicsScenePrivate::gestureEventHandler(), QQuickStackLayout::itemChange(), QQmlTableInstanceModel::object(), QQuickParticleDataHeap::pop(), QQmlTableInstanceModel::release(), QQuickTransformAnimatorHelperStore::release(), QPMCache::releaseKey(), QGeoTiledMappingManagerEngine::releaseMap(), QSet< T >::remove(), QGeoPositionInfo::removeAttribute(), QGeoSatelliteInfo::removeAttribute(), QWasmIntegration::removeBackingStore(), QV4DebuggerAgent::removeBreakPoint(), LinuxDmabufClientBufferIntegration::removeBuffer(), QDialogButtonBoxPrivate::removeButton(), QAbstractItemViewPrivate::removeEditor(), QQmlDebugServerImpl::removeEngine(), QNetworkAccessCache::removeEntry(), QQuickPixmapData::removeFromCache(), QGraphicsScenePrivate::removeItemHelper(), QDBusPlatformMenu::removeMenuItem(), QQmlDebugServerImpl::removeService(), QGeoTiledMapScenePrivate::removeTiles(), QDirectFbInput::removeWindow(), QQmlInspectorServiceImpl::removeWindow(), QXcbConnection::removeWindowEventListener(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QGeoTileRequestManagerPrivate::requestTiles(), QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(), QWindowsFileSystemWatcherEngineThread::run(), 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(), QWaylandIviApplicationPrivate::unregisterIviSurface(), QCFSocketNotifier::unregisterSocketNotifier(), QWaylandXdgOutputManagerV1Private::unregisterXdgOutput(), QFontPrivate::unsetFeature(), QSGSoftwareRenderableNodeUpdater::updateNodes(), QmlLsp::QQmlCodeModel::url2Path(), QQmlJSImportVisitor::visit(), QSGSoftwareRenderLoop::windowDestroyed(), and QWaylandTextInputV3Private::zwp_text_input_v3_destroy_resource().

◆ 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 980 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:

QHash<QString, int> hash;
hash.reserve(20000);
for (int i = 0; i < 20000; ++i)

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 931 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 941 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 900 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

◆ 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 1054 of file qhash.h.

Referenced by QMenuPrivate::_q_actionTriggered(), QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead(), QNetworkReplyImplPrivate::_q_copyReadyRead(), QMenuPrivate::_q_platformMenuAboutToShow(), CPP::WriteInitialization::acceptWidget(), QQuickTransformAnimatorHelperStore::acquire(), QSvgIconEngine::actualSize(), QPdfEnginePrivate::addConstantAlphaObject(), QNetworkAccessCache::addEntry(), QPdfEnginePrivate::addImage(), QMimeXMLProvider::addParents(), QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions(), QCocoaWindow::applyContentBorderThickness(), QNetworkRequest::attribute(), QNetworkRequestFactory::attribute(), QNetworkRequestFactory::attribute(), QQuickPath::attributeAt(), SharedTextureRegistry::bufferForId(), QmlLsp::QQmlCodeModel::buildPathsForRootUrl(), QSGOpenVGFontGlyphCacheManager::cache(), QQmlTableInstanceModel::cancel(), QGraphicsScenePrivate::cancelGesturesForChildren(), QHeaderViewPrivate::cascadingResize(), PlaceManagerEngineEsri::category(), QPlaceManagerEngineMapbox::category(), QPlaceManagerEngineOsm::category(), QHaikuCursor::changeCursor(), QQmlJSCodeGenerator::changedRegisterVariable(), PlaceManagerEngineEsri::childCategories(), QPlaceManagerEngineOsm::childCategories(), PlaceManagerEngineEsri::childCategoryIds(), QPlaceManagerEngineOsm::childCategoryIds(), QFontCache::clear(), QColorOutputPrivate::color(), QV4::ExecutionEngine::consoleCountHelper(), LinuxDmabufClientBufferIntegration::createBufferFor(), QItemEditorFactory::createEditor(), QQuickPath::createPath(), QWasmIntegration::createPlatformWindow(), QSGDefaultRenderContext::curveGlyphAtlas(), QDeclarativeSupportedCategoriesModel::data(), CustomDataProxy::data(), QQmlTableModel::data(), QGraphicsItem::data(), QAuthenticatorPrivate::digestMd5Response(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QMacStyle::drawControl(), QPdfEnginePrivate::drawTextItem(), QFont::featureValue(), QSGRhiShaderLinker::feedSamplers(), QWindowsContext::findClosestPlatformWindow(), QWindowsContext::findPlatformWindow(), QNetworkReplyHttpImplPrivate::finished(), QNetworkReplyImplPrivate::finished(), QMimeXMLProvider::genericIcon(), QGraphicsScenePrivate::gestureEventHandler(), QQmlTypeLoader::getQmldir(), QQmlTypeLoader::getScript(), QHttp2Connection::getStream(), QQmlTypeLoader::getType(), QMimeXMLProvider::globPatterns(), QOffscreenBackingStore::grabWindow(), QMimeXMLProvider::hasGlobDeleteAll(), QNetworkRequest::header(), QNetworkProxy::header(), QMimeXMLProvider::icon(), QQmlEnginePrivate::imageProvider(), QQmlTableInstanceModel::incubationStatus(), QDeclarativeSupportedCategoriesModel::index(), QParallelAnimationGroupPrivate::isUncontrolledAnimationFinished(), QSGRhiShaderLinker::linkTextureSubRects(), QQuickTableViewPrivate::loadedTableItem(), QMimeXMLProvider::localeComments(), QCocoaPrintDevice::macPaper(), QGraphicsScenePrivate::markDirty(), QMimeAllGlobPatterns::matchingGlobs(), QAndroidPlatformMenuBar::menuForId(), QDBusMenuBar::menuForTag(), QAndroidPlatformMenu::menuItemForId(), QFileSystemModelPrivate::name(), QSvgTinyDocument::namedNode(), QSvgTinyDocument::namedStyle(), QQmlMetaType::obtainCompilationUnit(), QQmlNativeDebugConnector::open(), QAuthenticator::option(), QFontFamilyDelegate::paint(), QCocoaTheme::palette(), PlaceManagerEngineEsri::parentCategoryId(), QAuthenticatorPrivate::parseDigestAuthenticationChallenge(), QAuthenticatorPrivate::parseHttpResponse(), QSvgIconEngine::pixmap(), QXcbConnection::platformWindowFromId(), QCoreTextFontDatabase::populateFontDatabase(), QPpdPrintDevice::printableMargins(), QCocoaPrintDevice::printableMargins(), QQmlMetaTypeData::propertyCache(), qt_aqua_get_known_size(), QQuickParticleEmitter::reclaculateGroupId(), QGestureManager::recycle(), QCFSocketNotifier::registerSocketNotifier(), QNetworkAccessCache::releaseEntry(), QV4DebuggerAgent::removeBreakPoint(), QNetworkAccessCache::removeEntry(), QFseventsFileSystemWatcherEngine::removePaths(), QQmlDebugServerImpl::removeService(), QSGAbstractSoftwareRenderer::renderableNode(), QQuickDesignerSupport::renderImageForItem(), QNetworkReplyHttpImplPrivate::replyDownloadData(), QNetworkAccessCache::requestEntryNow(), QMimeXMLProvider::resolveAlias(), QV4::CompiledData::CompilationUnit::resolvedType(), QQmlTypeCompiler::resolvedType(), SignalHandlerResolver::resolveSignalHandlerExpressions(), QDeclarativeSupportedCategoriesModel::rowCount(), QDefaultOutputMapping::screenNameForDeviceNode(), QMenuPrivate::scrollMenu(), QHeaderViewPrivate::sectionsAboutToBeChanged(), QGtk3FileDialogHelper::selectedNameFilter(), QGtk3FileDialogHelper::selectNameFilter(), QNetworkReplyHttpImplPrivate::sendCacheContents(), QEventDispatcherWin32Private::sendTimerEvent(), QQmlDebugServerImpl::service(), QQuickTableViewPrivate::setCurrentIndexFromKeyEvent(), QQmlTableModel::setData(), QQmlTableInstanceModel::setRequiredProperty(), VDMListDelegateDataType::setValue(), QQmlJSCodeGenerator::startInstruction(), QSGRhiDistanceFieldGlyphCache::storeGlyphs(), QGraphicsWidgetStyles::styleForWidget(), QMacStyle::subControlRect(), QSGRenderContext::textureForFactory(), QGeoTileRequestManagerPrivate::tileError(), QDBusConnectionPrivate::timerEvent(), QWindowsMouseHandler::translateTouchEvent(), QSvgIconEnginePrivate::tryLoad(), QSGRenderContext::unregisterFontengineForCleanup(), QCFSocketNotifier::unregisterSocketNotifier(), QFontCache::updateHitCountAndTimeStamp(), QGraphicsItemPrivate::updatePaintedViewBoundingRects(), QmlLsp::QQmlCodeModel::url2Path(), QQmlToolingSettings::value(), QItemEditorFactory::valuePropertyName(), QCommandLineParser::values(), QQnxIntegration::window(), QXcbConnection::windowEventListenerFromId(), 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 1059 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 1098 of file qhash.h.

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

Referenced by QGeoAreaMonitorPolling::activeMonitors(), QPlaceManagerEngineMapbox::childCategories(), and QQuickTableViewPrivate::dumpTable().

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

Friends And Related Symbol Documentation

◆ const_iterator

◆ 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 2459 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 1142 of file qhash.h.

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

◆ 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 565 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 565 of file qdatastream.h.

◆ qHash() [1/42]

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 101 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [2/42]

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 170 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [3/42]

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 172 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [4/42]

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/42]

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 1125 of file qhash.cpp.

◆ qHash() [6/42]

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 198 of file qhashfunctions.h.

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

+ Here is the call graph for this function:

◆ qHash() [7/42]

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/42]

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 191 of file qhashfunctions.h.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [9/42]

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 6252 of file qdatetime.cpp.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [10/42]

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/42]

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 2431 of file qhash.h.

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

+ Here is the call graph for this function:

◆ qHash() [12/42]

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/42]

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 966 of file qsslcertificate.cpp.

References seed.

◆ qHash() [14/42]

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/42]

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 204 of file qhashfunctions.h.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [16/42]

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 212 of file qtyperevision.cpp.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [17/42]

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 3685 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/42]

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 580 of file qversionnumber.cpp.

References hash, i, and seed.

◆ qHash() [19/42]

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 365 of file qhashfunctions.h.

References qHashMulti(), and seed.

+ Here is the call graph for this function:

◆ qHash() [20/42]

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 178 of file qhashfunctions.h.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [21/42]

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 1625 of file qhash.cpp.

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

+ Here is the call graph for this function:

◆ qHash() [22/42]

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 158 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [23/42]

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 113 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [24/42]

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 1643 of file qhash.cpp.

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

+ Here is the call graph for this function:

◆ qHash() [25/42]

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 117 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [26/42]

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 6267 of file qdatetime.cpp.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [27/42]

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

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

Note
This function is only available on platforms that support a native 128-bit integer type.

◆ qHash() [28/42]

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 125 of file qhashfunctions.h.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [29/42]

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 1139 of file qhash.cpp.

References qCpuHasFeature, qHashBits_fallback< ByteToWord >(), qt_qhash_seed, and seed.

+ Here is the call graph for this function:

◆ qHash() [30/42]

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() [31/42]

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() [32/42]

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 6278 of file qdatetime.cpp.

References qHash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [33/42]

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

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

Note
This function is only available on platforms that support a native 128-bit integer type.

◆ qHash() [34/42]

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 119 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [35/42]

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 109 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [36/42]

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 105 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [37/42]

template<typename Key , typename 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 182 of file qhashfunctions.h.

References seed.

◆ qHash() [38/42]

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 103 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [39/42]

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 111 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [40/42]

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 115 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [41/42]

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 107 of file qhashfunctions.h.

References QHashPrivate::hash(), and seed.

+ Here is the call graph for this function:

◆ qHash() [42/42]

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 168 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);
}

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 1089 of file qhash.cpp.

References qCpuHasFeature, qt_qhash_seed, and seed.

◆ 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 256 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
See also
qHashMultiCommutative, qHashRange

Definition at line 322 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 336 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

and

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);
}

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 344 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

and

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);
}

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 351 of file qhashfunctions.h.

References seed.

◆ QMultiHash< Key, T >

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

Definition at line 810 of file qhash.h.

◆ QSet< Key >

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

Definition at line 810 of file qhash.h.


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