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

\inmodule QtCore More...

#include <qhash.h>

+ Collaboration diagram for QMultiHash< 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
 
using mapped_type = T
 
using value_type = T
 
using size_type = qsizetype
 
using difference_type = qsizetype
 
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
 
typedef const_iterator ConstIterator
 

Public Member Functions

 QMultiHash () noexcept=default
 Constructs an empty hash.
 
 QMultiHash (std::initializer_list< std::pair< Key, T > > list)
 
template<typename InputIterator , QtPrivate::IfAssociativeIteratorHasKeyAndValue< InputIterator > = true>
 QMultiHash (InputIterator f, InputIterator l)
 
template<typename InputIterator , QtPrivate::IfAssociativeIteratorHasFirstAndSecond< InputIterator > = true>
 QMultiHash (InputIterator f, InputIterator l)
 
 QMultiHash (const QMultiHash &other) noexcept
 
 ~QMultiHash ()
 
QMultiHashoperator= (const QMultiHash &other) noexcept(std::is_nothrow_destructible< Node >::value)
 
 QMultiHash (QMultiHash &&other) noexcept
 
QMultiHashoperator= (QMultiHash &&other) noexcept(std::is_nothrow_destructible< Node >::value)
 
 QMultiHash (const QHash< Key, T > &other)
 Constructs a copy of other (which can be a QHash or a QMultiHash).
 
 QMultiHash (QHash< Key, T > &&other)
 
void swap (QMultiHash &other) noexcept
 
template<typename AKey = Key, typename AT = T>
QTypeTraits::compare_eq_result_container< QMultiHash, AKey, AToperator== (const QMultiHash &other) const noexcept
 
template<typename AKey = Key, typename AT = T>
QTypeTraits::compare_eq_result_container< QMultiHash, AKey, AToperator!= (const QMultiHash &other) const noexcept
 
qsizetype size () const noexcept
 
bool isEmpty () const noexcept
 
qsizetype capacity () const noexcept
 
void reserve (qsizetype size)
 
void squeeze ()
 
void detach ()
 
bool isDetached () const noexcept
 
bool isSharedWith (const QMultiHash &other) const noexcept
 
void clear () noexcept(std::is_nothrow_destructible< Node >::value)
 
qsizetype remove (const Key &key)
 
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
 
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
 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
 
QList< KeyuniqueKeys () const
 
QList< Keykeys () const
 Returns a list containing all the keys in the hash, in an arbitrary order.
 
QList< Keykeys (const T &value) const
 
QList< T > values () const
 Returns a list containing all the values in the hash, in an arbitrary order.
 
QList< T > values (const Key &key) 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 of all the values associated with the key, from the most recently inserted to the least recently inserted.
 
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 () noexcept
 
key_value_iterator keyValueEnd () noexcept
 
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 detach (const_iterator it)
 
iterator erase (const_iterator it)
 
qsizetype count () const noexcept
 
iterator find (const Key &key)
 
const_iterator find (const Key &key) const noexcept
 
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.
 
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
 
size_t bucket_count () const noexcept
 
bool empty () const noexcept
 
iterator replace (const Key &key, const T &value)
 Inserts a new item with the key and a value of value.
 
template<typename ... Args>
iterator emplaceReplace (const Key &key, Args &&... args)
 
template<typename ... Args>
iterator emplaceReplace (Key &&key, Args &&... args)
 Inserts a new element into the container.
 
QMultiHashoperator+= (const QMultiHash &other)
 Inserts all the items in the other hash into this hash and returns a reference to this hash.
 
QMultiHash operator+ (const QMultiHash &other) const
 Returns a hash that contains all the items in this hash in addition to all the items in other.
 
bool contains (const Key &key, const T &value) const noexcept
 
qsizetype remove (const Key &key, const T &value)
 
qsizetype count (const Key &key) const noexcept
 
qsizetype count (const Key &key, const T &value) const noexcept
 
iterator find (const Key &key, const T &value)
 
const_iterator find (const Key &key, const T &value) const noexcept
 
const_iterator constFind (const Key &key, const T &value) const noexcept
 
QMultiHashunite (const QMultiHash &other)
 
QMultiHashunite (const QHash< Key, T > &other)
 
QMultiHashunite (QHash< Key, T > &&other)
 
QPair< iterator, iteratorequal_range (const Key &key)
 
QPair< const_iterator, const_iteratorequal_range (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.
 

Static Public Member Functions

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

Friends

class iterator
 
class const_iterator
 

Related Symbols

(Note that these are not member symbols.)

template< class Key, class T > QDataStreamoperator<< (QDataStream &out, const QMultiHash< Key, T > &hash)
 Writes the hash hash to stream out.
 
template< class Key, class T > QDataStreamoperator>> (QDataStream &in, QMultiHash< Key, T > &hash)
 Reads a hash from stream in into hash.
 
template< class Key, class T > size_t qHash (const QMultiHash< Key, T > &key, size_t seed=0)
 
template< typename Key, typename T, typename Predicate > qsizetype erase_if (QMultiHash< Key, T > &hash, Predicate pred)
 

Detailed Description

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

\inmodule QtCore

The QMultiHash class is a convenience QHash subclass that provides multi-valued hashes.

\reentrant

QMultiHash<Key, T> is one of Qt's generic \l{container classes}. It inherits QHash and extends it with a few convenience functions that make it more suitable than QHash for storing multi-valued hashes. A multi-valued hash is a hash that allows multiple values with the same key.

QMultiHash mostly mirrors QHash's API. For example, you can use isEmpty() to test whether the hash is empty, and you can traverse a QMultiHash using QHash's iterator classes (for example, QHashIterator). But opposed to QHash, it provides an insert() function that allows the insertion of multiple items with the same key. The replace() function corresponds to QHash::insert(). It also provides convenient operator+() and operator+=().

Unlike QMultiMap, QMultiHash does not provide and ordering of the inserted items. The only guarantee is that items that share the same key will appear consecutively, from the most recently to the least recently inserted value.

Example:

QMultiHash<QString, int> hash1, hash2, hash3;
hash1.insert("plenty", 100);
hash1.insert("plenty", 2000);
// hash1.size() == 2
hash2.insert("plenty", 5000);
// hash2.size() == 1
hash3 = hash1 + hash2;
// hash3.size() == 3
\inmodule QtCore
Definition qhash.h:1348
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1930

Unlike QHash, QMultiHash provides no operator[]. Use value() or replace() if you want to access the most recently inserted item with a certain key.

If you want to retrieve all the values for a single key, you can use values(const Key &key), which returns a QList<T>:

QList<int> values = hash.values("plenty");
for (auto i : std::as_const(values))
cout << i << endl;
Definition qlist.h:74
QHash< int, QWidget * > hash
[35multi]
GLenum GLsizei GLsizei GLint * values
[15]

The items that share the same key are available from most recently to least recently inserted.

A more efficient approach is to call find() to get the STL-style iterator for the first item with a key and iterate from there:

auto i = hash.constFind("plenty");
while (i != hash.cend() && i.key() == "plenty") {
cout << i.value() << endl;
++i;
}

QMultiHash'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 *. In addition, QMultiHash's key type must provide operator==(), and there must also be a qHash() function in the type's namespace that returns a hash value for an argument of the key's type. See the QHash documentation for details.

See also
QHash, QHashIterator, QMutableHashIterator, QMultiMap

Definition at line 1347 of file qhash.h.

Member Typedef Documentation

◆ const_key_value_iterator

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

\inmodule QtCore

Since
5.10

The QMap::const_key_value_iterator typedef provides an STL-style const iterator for QMultiHash and QMultiHash.

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

See also
QKeyValueIterator

Definition at line 1822 of file qhash.h.

◆ const_reference

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

Definition at line 1363 of file qhash.h.

◆ ConstIterator

template<typename Key , typename T >
typedef const_iterator QMultiHash< Key, T >::ConstIterator

Definition at line 1902 of file qhash.h.

◆ difference_type

template<typename Key , typename T >
using QMultiHash< Key, T >::difference_type = qsizetype

Definition at line 1361 of file qhash.h.

◆ Iterator

template<typename Key , typename T >
typedef iterator QMultiHash< Key, T >::Iterator

Definition at line 1901 of file qhash.h.

◆ key_type

template<typename Key , typename T >
using QMultiHash< Key, T >::key_type = Key

Definition at line 1357 of file qhash.h.

◆ key_value_iterator

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

\inmodule QtCore

Since
5.10

The QMap::key_value_iterator typedef provides an STL-style iterator for QMultiHash and QMultiHash.

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

See also
QKeyValueIterator

Definition at line 1823 of file qhash.h.

◆ mapped_type

template<typename Key , typename T >
using QMultiHash< Key, T >::mapped_type = T

Definition at line 1358 of file qhash.h.

◆ reference

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

Definition at line 1362 of file qhash.h.

◆ size_type

template<typename Key , typename T >
using QMultiHash< Key, T >::size_type = qsizetype

Definition at line 1360 of file qhash.h.

◆ value_type

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

Definition at line 1359 of file qhash.h.

Constructor & Destructor Documentation

◆ QMultiHash() [1/8]

template<typename Key , typename T >
template< class Key, class T > QMultiHash< Key, T >::QMultiHash ( )
defaultnoexcept

Constructs an empty hash.

Referenced by QMultiHash< Key, T >::equal_range(), QMultiHash< Key, T >::find(), and QMultiHash< Key, T >::operator[]().

+ Here is the caller graph for this function:

◆ QMultiHash() [2/8]

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

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

This function is only available if the program is being compiled in C++11 mode.

Definition at line 1366 of file qhash.h.

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

+ Here is the call graph for this function:

◆ QMultiHash() [3/8]

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

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

Definition at line 1377 of file qhash.h.

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

+ Here is the call graph for this function:

◆ QMultiHash() [4/8]

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

Definition at line 1385 of file qhash.h.

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

+ Here is the call graph for this function:

◆ QMultiHash() [5/8]

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

Definition at line 1392 of file qhash.h.

References d.

◆ ~QMultiHash()

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

Definition at line 1398 of file qhash.h.

References d.

◆ QMultiHash() [6/8]

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

Definition at line 1420 of file qhash.h.

References d.

◆ QMultiHash() [7/8]

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

Constructs a copy of other (which can be a QHash or a QMultiHash).

Definition at line 1432 of file qhash.h.

◆ QMultiHash() [8/8]

template<typename Key , typename T >
QMultiHash< Key, T >::QMultiHash ( QHash< Key, T > &&  other)
inlineexplicit

Definition at line 1436 of file qhash.h.

References other(), and QMultiHash< Key, T >::unite().

+ Here is the call graph for this function:

Member Function Documentation

◆ asKeyValueRange() [1/4]

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

Definition at line 1842 of file qhash.h.

Referenced by VarBindingTypeValidatorPass::VarBindingTypeValidatorPass().

+ Here is the caller graph for this function:

◆ asKeyValueRange() [2/4]

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

Definition at line 1844 of file qhash.h.

◆ asKeyValueRange() [3/4]

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

Definition at line 1843 of file qhash.h.

◆ asKeyValueRange() [4/4]

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

Definition at line 1845 of file qhash.h.

◆ begin() [1/2]

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

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

See also
constBegin(), end()

Definition at line 1826 of file qhash.h.

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

Referenced by QGradientCache::addCacheElement(), QQuickItemViewPrivate::applyModelChanges(), QMultiHash< Key, T >::constKeyValueBegin(), QDomNamedNodeMapPrivate::item(), QMultiHash< Key, T >::keyBegin(), QMultiHash< Key, T >::keys(), QMultiHash< Key, T >::keyValueBegin(), QMultiHash< Key, T >::keyValueBegin(), QDBusConnectionPrivate::objectDestroyed(), QQmlProfilerServiceImpl::startProfiling(), QQmlProfilerServiceImpl::stopProfiling(), and QMultiHash< 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 > QMultiHash< Key, T >::const_iterator QMultiHash< Key, T >::begin ( ) const
inlinenoexcept

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

Definition at line 1827 of file qhash.h.

References d.

◆ bucket_count()

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

Definition at line 1958 of file qhash.h.

References d.

◆ capacity()

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

Definition at line 1494 of file qhash.h.

References d.

Referenced by QMultiHash< Key, T >::reserve().

+ Here is the caller graph for this function:

◆ cbegin()

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

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

See also
begin(), cend()

Definition at line 1828 of file qhash.h.

References d.

Referenced by QQmlBindPrivate::buildBindEntries().

+ Here is the caller graph for this function:

◆ cend()

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

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

See also
cbegin(), end()

Definition at line 1832 of file qhash.h.

Referenced by QQmlBindPrivate::buildBindEntries(), QPersistentModelIndexData::create(), QAbstractItemModelPrivate::invalidatePersistentIndex(), and QAbstractItemModelPrivate::rowsRemoved().

+ Here is the caller graph for this function:

◆ clear()

template<typename Key , typename T >
template< class Key, class T > void QMultiHash< Key, T >::clear ( )
inlinenoexcept
Since
4.3

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

See also
remove()

Definition at line 1511 of file qhash.h.

References d.

Referenced by QOpenGL2GradientCache::~QOpenGL2GradientCache(), QQuickItemViewPrivate::applyModelChanges(), QTextFormatCollection::clear(), QDomNamedNodeMapPrivate::clearMap(), QAbstractItemModelPrivate::invalidatePersistentIndexes(), QOpenGL2GradientCache::invalidateResource(), QTextDocumentLayoutPrivate::layoutTable(), and QQuickItemViewChangeSet::reset().

+ Here is the caller graph for this function:

◆ constBegin()

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

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

See also
begin(), constEnd()

Definition at line 1829 of file qhash.h.

References d.

Referenced by QDomNamedNodeMapPrivate::clearMap(), QDomNamedNodeMapPrivate::clone(), QQmlJSScope::methods(), QDomNamedNodeMapPrivate::namedItemNS(), resourceDataFileMapRecursion(), and QDomDocumentTypePrivate::save().

+ Here is the caller graph for this function:

◆ constEnd()

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

◆ constFind() [1/2]

◆ constFind() [2/2]

template<typename Key , typename T >
template< class Key, class T > typename QMultiHash< Key, T >::const_iterator QMultiHash< Key, T >::constFind ( const Key key,
const T &  value 
) const
inlinenoexcept
Since
4.3

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

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

Definition at line 2081 of file qhash.h.

References QMultiHash< Key, T >::constEnd(), QMultiHash< Key, T >::constFind(), QMultiHash< Key, T >::end(), and i.

+ Here is the call graph for this function:

◆ constKeyValueBegin()

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

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

See also
keyValueBegin()

Definition at line 1839 of file qhash.h.

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

+ Here is the call graph for this function:

◆ constKeyValueEnd()

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

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

See also
constKeyValueBegin()

Definition at line 1841 of file qhash.h.

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

+ Here is the call graph for this function:

◆ contains() [1/2]

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

Definition at line 1567 of file qhash.h.

References d.

Referenced by QDomNamedNodeMapPrivate::contains(), QQmlPartsModel::destroyingPackage(), QQmlJSImportVisitor::endVisit(), QQmlJSScope::hasMethod(), QQmlJSScope::isIdInCurrentQmlScopes(), QTreeModel::sortItems(), QQmlJSImportVisitor::visit(), QQmlJSImportVisitor::visit(), and QQmlJSImportVisitor::visit().

+ Here is the caller graph for this function:

◆ contains() [2/2]

template<typename Key , typename T >
template< class Key, class T > bool QMultiHash< Key, T >::contains ( const Key key,
const T &  value 
) const
inlinenoexcept
Since
4.3

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

See also
contains()

Definition at line 1993 of file qhash.h.

References d, and QMultiHash< Key, T >::isEmpty().

+ Here is the call graph for this function:

◆ count() [1/3]

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

Definition at line 1903 of file qhash.h.

References QMultiHash< Key, T >::size().

+ Here is the call graph for this function:

◆ count() [2/3]

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

Definition at line 2033 of file qhash.h.

References d, e, and it.

◆ count() [3/3]

template<typename Key , typename T >
template< class Key, class T > qsizetype QMultiHash< Key, T >::count ( const Key key,
const T &  value 
) const
inlinenoexcept
Since
4.3

Returns the number of items with the key and value.

See also
count()

Definition at line 2050 of file qhash.h.

References d, e, and it.

◆ detach() [1/2]

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

Definition at line 1507 of file qhash.h.

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

Referenced by QMultiHash< Key, T >::begin(), QMultiHash< Key, T >::emplace(), QMultiHash< Key, T >::emplaceReplace(), QMultiHash< Key, T >::equal_range(), QMultiHash< Key, T >::erase(), QMultiHash< Key, T >::find(), QMultiHash< Key, T >::find(), QMultiHash< Key, T >::operator[](), QMultiHash< Key, T >::remove(), QMultiHash< Key, T >::remove(), QMultiHash< Key, T >::take(), and QMultiHash< Key, T >::unite().

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

◆ detach() [2/2]

template<typename Key , typename T >
iterator QMultiHash< Key, T >::detach ( const_iterator  it)
inline

Definition at line 1847 of file qhash.h.

References d, e, i, it, and Q_ASSERT.

◆ emplace() [1/2]

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

Definition at line 1936 of file qhash.h.

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

Referenced by QMultiHash< Key, T >::emplace(), QMultiHash< Key, T >::insert(), and QMultiHash< Key, T >::unite().

+ 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 > QMultiHash< Key, T >::iterator QMultiHash< 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.

If there is already an item with the same key in the hash, this function will simply create a new one. (This behavior is different from replace(), which overwrites the value of an existing item.)

Returns an iterator pointing to the new element.

See also
insert

Definition at line 1942 of file qhash.h.

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

+ Here is the call graph for this function:

◆ emplaceReplace() [1/2]

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

Definition at line 1969 of file qhash.h.

References args, QMultiHash< Key, T >::emplaceReplace(), and Key.

Referenced by QMultiHash< Key, T >::emplaceReplace(), and QMultiHash< Key, T >::replace().

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

◆ emplaceReplace() [2/2]

template<typename Key , typename T >
template<typename ... Args>
template< class Key, class T > template< typename ...Args > QMultiHash< Key, T >::iterator QMultiHash< Key, T >::emplaceReplace ( 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.

If there is already an item with the same key in the hash, that item's value is replaced with a value constructed from args.

Returns an iterator pointing to the new element.

See also
replace, emplace

Definition at line 1975 of file qhash.h.

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

+ Here is the call graph for this function:

◆ empty()

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

Definition at line 1961 of file qhash.h.

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

+ Here is the call graph for this function:

◆ end() [1/2]

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

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

Definition at line 1831 of file qhash.h.

◆ end() [2/2]

◆ equal_range() [1/2]

template<typename Key , typename T >
template< class Key, class T > QPair< iterator, iterator > QMultiHash< Key, T >::equal_range ( const Key key)
inline
Since
5.7

Returns a pair of iterators delimiting the range of values {[first, second)}, that are stored under key. If the range is empty then both iterators will be equal to end().

Definition at line 2128 of file qhash.h.

References QMultiHash< Key, T >::QMultiHash(), copy(), QMultiHash< Key, T >::detach(), QMultiHash< Key, T >::isDetached(), and qMakePair().

Referenced by QtQuickPrivate::beginDeferred(), VarBindingTypeValidatorPass::onBinding(), AttachedPropertyReuse::onRead(), QQmlJSScope::ownPropertyBindingsInQmlIROrder(), and QInotifyFileSystemWatcherEngine::removePaths().

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

◆ equal_range() [2/2]

template<typename Key , typename T >
template< class Key, class T > QPair< const_iterator, const_iterator > QMultiHash< Key, T >::equal_range ( 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.

Since
5.7

Definition at line 2136 of file qhash.h.

References d, QMultiHash< Key, T >::end(), it, and qMakePair().

+ Here is the call graph for this function:

◆ erase()

template<typename Key , typename T >
iterator QMultiHash< Key, T >::erase ( const_iterator  it)
inline

Definition at line 1873 of file qhash.h.

References d, QMultiHash< Key, T >::detach(), e, i, QHashPrivate::Data< Node >::Bucket::isUnused(), it, iter, next, Q_ASSERT, QHashPrivate::Data< Node >::Bucket::toBucketIndex(), and QHashPrivate::Data< Node >::Bucket::toIterator().

Referenced by QGradientCache::addCacheElement(), QAbstractItemModelPrivate::columnsInserted(), QAbstractItemModelPrivate::columnsRemoved(), QAbstractItemModelPrivate::invalidatePersistentIndex(), QAbstractItemModelPrivate::movePersistentIndexes(), QInotifyFileSystemWatcherEngine::removePaths(), QAbstractItemModelPrivate::rowsInserted(), and QAbstractItemModelPrivate::rowsRemoved().

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

◆ find() [1/4]

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

Definition at line 1904 of file qhash.h.

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

Referenced by QQmlPartsModel::indexOf(), QDomNamedNodeMapPrivate::namedItem(), QQmlPartsModel::release(), and QQmlImportInstance::resolveType().

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

◆ find() [2/4]

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

Definition at line 1917 of file qhash.h.

References QMultiHash< Key, T >::constFind().

+ Here is the call graph for this function:

◆ find() [3/4]

template<typename Key , typename T >
template< class Key, class T > typename QMultiHash< Key, T >::iterator QMultiHash< Key, T >::find ( const Key key,
const T &  value 
)
inline
Since
4.3

Returns an iterator pointing to the item with the key and value. If the hash contains no such item, the function returns end().

If the hash contains multiple items with the key and value, the iterator returned points to the most recently inserted item.

Definition at line 2068 of file qhash.h.

References QMultiHash< Key, T >::QMultiHash(), QMultiHash< Key, T >::constFind(), copy(), QMultiHash< Key, T >::detach(), QMultiHash< Key, T >::end(), QMultiHash< Key, T >::isDetached(), QMultiHash< Key, T >::isEmpty(), and it.

+ Here is the call graph for this function:

◆ find() [4/4]

template<typename Key , typename T >
template< class Key, class T > typename QMultiHash< Key, T >::const_iterator QMultiHash< Key, T >::find ( const Key key,
const T &  value 
) const
inlinenoexcept
Since
4.3 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 2077 of file qhash.h.

References QMultiHash< Key, T >::constFind().

+ Here is the call graph for this function:

◆ insert()

template<typename Key , typename T >
template< class Key, class T > QMultiHash< Key, T >::iterator QMultiHash< 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 same key in the hash, this function will simply create a new one. (This behavior is different from replace(), which overwrites the value of an existing item.)

See also
replace()

Definition at line 1930 of file qhash.h.

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

Referenced by QDomDocumentTypePrivate::QDomDocumentTypePrivate(), QMultiHash< Key, T >::QMultiHash(), QMultiHash< Key, T >::QMultiHash(), VarBindingTypeValidatorPass::VarBindingTypeValidatorPass(), QGradientCache::addCacheElement(), QInotifyFileSystemWatcherEngine::addPaths(), QPersistentModelIndexData::create(), QQmlSA::BindingsPrivate::createBindings(), QQmlSA::BindingsPrivate::createBindings(), QQmlSA::MethodsPrivate::createMethods(), QTextFormatCollection::indexForFormat(), QDomDocumentTypePrivate::insertAfter(), QDomDocumentTypePrivate::insertBefore(), QAbstractItemModelPrivate::Persistent::insertMultiAtEnd(), QTextDocumentLayoutPrivate::layoutTable(), QQmlPartsModel::object(), AttachedPropertyReuse::onRead(), QQuickItemViewPrivate::removeItem(), QDomDocumentTypePrivate::replaceChild(), QDBusConnectionPrivate::setConnection(), QDomNamedNodeMapPrivate::setNamedItem(), QDomNamedNodeMapPrivate::setNamedItemNS(), QQmlQmldirData::setPriority(), QMultiHash< Key, T >::unite(), and QMultiHash< Key, T >::unite().

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

◆ isDetached()

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

Definition at line 1508 of file qhash.h.

References d.

Referenced by QMultiHash< Key, T >::emplace(), QMultiHash< Key, T >::emplaceReplace(), QMultiHash< Key, T >::equal_range(), QMultiHash< Key, T >::find(), QMultiHash< Key, T >::operator[](), and QMultiHash< Key, T >::reserve().

+ Here is the caller graph for this function:

◆ isEmpty()

◆ isSharedWith()

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

Definition at line 1509 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 QMultiHash< Key, T >::key ( const T &  value) const
inlinenoexcept

Definition at line 1590 of file qhash.h.

References Key.

◆ key() [2/2]

template<typename Key , typename T >
template< class Key, class T > Key QMultiHash< 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 QMultiHash's internal data structure is optimized for fast lookup by key, not by value.

Definition at line 1597 of file qhash.h.

◆ keyBegin()

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

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

See also
keyEnd()

Definition at line 1834 of file qhash.h.

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

Referenced by QMultiHash< Key, T >::keys(), and QQmlProfilerServiceImpl::stateAboutToBeChanged().

+ 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 > QMultiHash< Key, T >::key_iterator QMultiHash< Key, T >::keyEnd ( ) const
inlinenoexcept
Since
5.6

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

See also
keyBegin()

Definition at line 1835 of file qhash.h.

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

Referenced by QMultiHash< Key, T >::keys(), and QQmlProfilerServiceImpl::stateAboutToBeChanged().

+ 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 > QMultiHash< Key, T >::keys ( ) const
inline

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

Keys that occur multiple times in the hash also occur multiple times in the list.

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

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

+ Here is the call graph for this function:

◆ keys() [2/2]

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

Definition at line 1665 of file qhash.h.

References QMultiHash< Key, T >::begin(), QMultiHash< 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 > QMultiHash< Key, T >::const_key_value_iterator QMultiHash< Key, T >::keyValueBegin ( ) const
inlinenoexcept
Since
5.10

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

See also
keyValueEnd()

Definition at line 1838 of file qhash.h.

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

+ Here is the call graph for this function:

◆ keyValueBegin() [2/2]

template<typename Key , typename T >
template< class Key, class T > QMultiHash< Key, T >::key_value_iterator QMultiHash< Key, T >::keyValueBegin ( )
inlinenoexcept
Since
5.10

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

See also
keyValueEnd()

Definition at line 1836 of file qhash.h.

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

+ Here is the call graph for this function:

◆ keyValueEnd() [1/2]

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

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

See also
keyValueBegin()

Definition at line 1840 of file qhash.h.

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

+ Here is the call graph for this function:

◆ keyValueEnd() [2/2]

template<typename Key , typename T >
template< class Key, class T > QMultiHash< Key, T >::key_value_iterator QMultiHash< Key, T >::keyValueEnd ( )
inlinenoexcept
Since
5.10

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

See also
keyValueBegin()

Definition at line 1837 of file qhash.h.

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

+ Here is the call graph for this function:

◆ load_factor()

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

Definition at line 1956 of file qhash.h.

References d.

◆ max_bucket_count()

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

Definition at line 1959 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 QMultiHash< Key, T >::max_load_factor ( )
inlinestaticnoexcept

Definition at line 1957 of file qhash.h.

◆ operator!=()

template<typename Key , typename T >
template<typename AKey = Key, typename AT = T>
QTypeTraits::compare_eq_result_container< QMultiHash, AKey, AT > QMultiHash< Key, T >::operator!= ( const QMultiHash< Key, T > &  other) const
inlinenoexcept

Definition at line 1483 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 > QMultiHash QMultiHash< Key, T >::operator+ ( const QMultiHash< Key, T > &  other) const
inline

Returns a hash that contains all the items in this hash in addition to all the items in other.

If a key is common to both hashes, the resulting hash will contain the key multiple times.

See also
operator+=()

Definition at line 1990 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 > QMultiHash & QMultiHash< Key, T >::operator+= ( const QMultiHash< Key, T > &  other)
inline

Inserts all the items in the other hash into this hash and returns a reference to this hash.

See also
unite(), insert()

Definition at line 1988 of file qhash.h.

References QMultiHash< Key, T >::unite().

+ Here is the call graph for this function:

◆ operator=() [1/2]

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

Definition at line 1407 of file qhash.h.

References d, o, and other().

+ Here is the call graph for this function:

◆ operator=() [2/2]

template<typename Key , typename T >
QMultiHash & QMultiHash< Key, T >::operator= ( QMultiHash< Key, T > &&  other)
inlinenoexcept

Definition at line 1425 of file qhash.h.

References other(), and QMultiHash< Key, T >::swap().

+ Here is the call graph for this function:

◆ operator==()

template<typename Key , typename T >
template<typename AKey = Key, typename AT = T>
QTypeTraits::compare_eq_result_container< QMultiHash, AKey, AT > QMultiHash< Key, T >::operator== ( const QMultiHash< Key, T > &  other) const
inlinenoexcept

Definition at line 1449 of file qhash.h.

References d, e, it, QHashPrivate::MultiNodeChain< T >::next, other(), Q_ASSERT, and QHashPrivate::MultiNodeChain< T >::value.

+ Here is the call graph for this function:

◆ operator[]() [1/2]

template<typename Key , typename T >
template< class Key, class T > T & QMultiHash< 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.

If the hash contains multiple items with the key, this function returns a reference to the most recently inserted value.

See also
insert(), value()

Definition at line 1633 of file qhash.h.

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

+ Here is the call graph for this function:

◆ operator[]() [2/2]

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

Definition at line 1646 of file qhash.h.

◆ remove() [1/2]

template<typename Key , typename T >
template< class Key, class T > qsizetype QMultiHash< Key, T >::remove ( const Key key)
inline
Since
4.3

Removes all the items that have the key from the hash. Returns the number of items removed.

See also
remove()

Definition at line 1519 of file qhash.h.

References d, QMultiHash< Key, T >::detach(), QHashPrivate::MultiNode< Key, T >::freeChain(), QMultiHash< Key, T >::isEmpty(), it, and Q_ASSERT.

Referenced by QQmlProfilerServiceImpl::engineRemoved(), QDomDocumentTypePrivate::removeChild(), QDomNamedNodeMapPrivate::removeNamedItem(), QAbstractItemModelPrivate::removePersistentIndexData(), and QDomDocumentTypePrivate::replaceChild().

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

◆ remove() [2/2]

template<typename Key , typename T >
template< class Key, class T > qsizetype QMultiHash< Key, T >::remove ( const Key key,
const T &  value 
)
inline
Since
4.3

Removes all the items that have the key and the value value from the hash. Returns the number of items removed.

See also
remove()

Definition at line 2003 of file qhash.h.

References d, QMultiHash< Key, T >::detach(), e, QMultiHash< Key, T >::isEmpty(), it, and Q_ASSERT.

+ Here is the call graph for this function:

◆ removeIf()

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

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

The function supports predicates which take either an argument of type {QMultiHash<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 1537 of file qhash.h.

References QtPrivate::associative_erase_if().

+ Here is the call graph for this function:

◆ replace()

template<typename Key , typename T >
template< class Key, class T > QMultiHash< Key, T >::iterator QMultiHash< Key, T >::replace ( 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.

If there are multiple items with the key, the most recently inserted item's value is replaced with value.

See also
insert()

Definition at line 1963 of file qhash.h.

References QMultiHash< Key, T >::emplaceReplace().

Referenced by QQuickItemViewPrivate::removeItem().

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

◆ reserve()

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

Definition at line 1495 of file qhash.h.

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

Referenced by QMultiHash< Key, T >::squeeze().

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

◆ size()

template<typename Key , typename T >
qsizetype QMultiHash< Key, T >::size ( ) const
inlinenoexcept

Definition at line 1490 of file qhash.h.

Referenced by QGradientCache::addCacheElement(), QMultiHash< Key, T >::count(), QDomNamedNodeMapPrivate::length(), QDomElementPrivate::save(), QSortFilterProxyModelPrivate::store_persistent_indexes(), and RCCFileInfo::writeDataInfo().

+ Here is the caller graph for this function:

◆ squeeze()

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

Definition at line 1505 of file qhash.h.

References QMultiHash< Key, T >::reserve().

+ Here is the call graph for this function:

◆ swap()

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

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

Definition at line 1441 of file qhash.h.

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

Referenced by QMultiHash< Key, T >::operator=().

+ 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 QMultiHash< Key, T >::take ( const Key key)
inline

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

If the item does not exist in the hash, the function simply returns a \l{default-constructed value}. If there are multiple items for key in the hash, only the most recently inserted one is removed.

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

See also
remove()

Definition at line 1541 of file qhash.h.

References d, QMultiHash< Key, T >::detach(), e, QMultiHash< Key, T >::isEmpty(), it, and Q_ASSERT.

Referenced by QQuickGridViewPrivate::applyInsertionChange(), and QQuickListViewPrivate::applyInsertionChange().

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

◆ uniqueKeys()

template<typename Key , typename T >
template< class Key, class T > QList< Key > QMultiHash< Key, T >::uniqueKeys ( ) const
inline
Since
5.13

Returns a list containing all the keys in the map. Keys that occur multiple times in the map occur only once in the returned list.

See also
keys(), values()

Definition at line 1651 of file qhash.h.

References d, and i.

◆ unite() [1/3]

template<typename Key , typename T >
template< class Key, class T > QMultiHash & QMultiHash< Key, T >::unite ( const QHash< Key, T > &  other)
inline
Since
6.0

Inserts all the items in the other hash into this hash and returns a reference to this hash.

See also
insert()

Definition at line 2108 of file qhash.h.

References QMultiHash< Key, T >::insert(), and other().

+ Here is the call graph for this function:

◆ unite() [2/3]

template<typename Key , typename T >
template< class Key, class T > QMultiHash & QMultiHash< Key, T >::unite ( const QMultiHash< Key, T > &  other)
inline
Since
5.13

Inserts all the items in the other hash into this hash and returns a reference to this hash.

See also
insert()

Definition at line 2093 of file qhash.h.

References copy(), QMultiHash< Key, T >::detach(), QMultiHash< Key, T >::insert(), QMultiHash< Key, T >::isEmpty(), and other().

Referenced by QMultiHash< Key, T >::QMultiHash(), Generator::generateCode(), QMultiHash< Key, T >::operator+=(), and QMultiHash< Key, T >::unite().

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

◆ unite() [3/3]

template<typename Key , typename T >
QMultiHash & QMultiHash< Key, T >::unite ( QHash< Key, T > &&  other)
inline

Definition at line 2115 of file qhash.h.

References QMultiHash< Key, T >::emplace(), QMultiHash< Key, T >::end(), it, other(), and QMultiHash< Key, T >::unite().

+ Here is the call graph for this function:

◆ value() [1/2]

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

Definition at line 1618 of file qhash.h.

Referenced by QDomNamedNodeMapPrivate::setNamedItem().

+ Here is the caller graph for this function:

◆ value() [2/2]

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

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.

If there are multiple items for the key in the hash, the value of the most recently inserted one is returned.

Definition at line 1625 of file qhash.h.

◆ values() [1/2]

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

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

If a key is associated with multiple values, all of its values will be in the list, and not just the most recently inserted one.

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

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

Referenced by QTextDocumentLayoutPrivate::drawTableCell(), QQmlJSImportVisitor::endVisit(), QTextDocumentLayoutPrivate::hitTest(), QTextDocumentLayoutPrivate::layoutCell(), and QMultiHash< Key, T >::values().

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

◆ values() [2/2]

template<typename Key , typename T >
template< class Key, class T > QList< T > QMultiHash< Key, T >::values ( const Key key) 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 of all the values associated with the key, from the most recently inserted to the least recently inserted.

See also
count(), insert()

Definition at line 1677 of file qhash.h.

References d, e, and QMultiHash< Key, T >::values().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ const_iterator

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

Definition at line 1796 of file qhash.h.

◆ erase_if()

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

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

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

Returns the number of elements removed, if any.

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

◆ operator<<()

template<typename Key , typename T >
template< class Key, class T > QDataStream & operator<< ( QDataStream out,
const QMultiHash< 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 449 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,
QMultiHash< 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 449 of file qdatastream.h.

◆ qHash()

template<typename Key , typename T >
template< class Key, class T > size_t qHash ( const QMultiHash< 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 2209 of file qhash.h.

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

+ Here is the call graph for this function:

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