Qt 4.8
Classes | Public Types | Public Functions | Private Types | Private Functions | Static Private Functions | Properties | Friends | Related Functions | List of all members
QHash< Key, T > Class Template Reference

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

#include <qdatastream.h>

Inheritance diagram for QHash< Key, T >:
QMultiHash< Key, T >

Classes

class  const_iterator
 The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash. More...
 
class  iterator
 The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash. More...
 

Public Types

typedef const_iterator ConstIterator
 Qt-style synonym for QHash::const_iterator. More...
 
typedef qptrdiff difference_type
 Typedef for ptrdiff_t. More...
 
typedef iterator Iterator
 Qt-style synonym for QHash::iterator. More...
 
typedef Key key_type
 Typedef for Key. More...
 
typedef T mapped_type
 Typedef for T. More...
 
typedef int size_type
 Typedef for int. More...
 

Public Functions

iterator begin ()
 Returns an STL-style iterator pointing to the first item in the hash. More...
 
const_iterator begin () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int capacity () const
 Returns the number of buckets in the QHash's internal hash table. More...
 
void clear ()
 Removes all items from the hash. More...
 
const_iterator constBegin () const
 Returns a const STL-style iterator pointing to the first item in the hash. More...
 
const_iterator constEnd () const
 Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash. More...
 
const_iterator constFind (const Key &key) const
 Returns an iterator pointing to the item with the key in the hash. More...
 
bool contains (const Key &key) const
 Returns true if the hash contains an item with the key; otherwise returns false. More...
 
int count (const Key &key) const
 Returns the number of items associated with the key. More...
 
int count () const
 Same as size(). More...
 
void detach ()
 Detaches this hash from any other hashes with which it may share data. More...
 
bool empty () const
 This function is provided for STL compatibility. More...
 
iterator end ()
 Returns an STL-style iterator pointing to the imaginary item after the last item in the hash. More...
 
const_iterator end () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
iterator erase (iterator it)
 Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator to the next item in the hash. More...
 
iterator find (const Key &key)
 Returns an iterator pointing to the item with the key in the hash. More...
 
const_iterator find (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. More...
 
iterator insert (const Key &key, const T &value)
 Inserts a new item with the key and a value of value. More...
 
iterator insertMulti (const Key &key, const T &value)
 Inserts a new item with the key and a value of value. More...
 
bool isDetached () const
 Returns true if the hash's internal data isn't shared with any other hash object; otherwise returns false. More...
 
bool isEmpty () const
 Returns true if the hash contains no items; otherwise returns false. More...
 
bool isSharedWith (const QHash< Key, T > &other) const
 
const Key key (const T &value) const
 Returns the first key mapped to value. More...
 
const Key key (const T &value, const Key &defaultKey) const
 Returns the first key mapped to value, or defaultKey if the hash contains no item mapped to value. More...
 
QList< Key > keys () const
 Returns a list containing all the keys in the hash, in an arbitrary order. More...
 
QList< Key > keys (const T &value) const
 Returns a list containing all the keys associated with value value, in an arbitrary order. More...
 
bool operator!= (const QHash< Key, T > &other) const
 Returns true if other is not equal to this hash; otherwise returns false. More...
 
QHash< Key, T > & operator= (const QHash< Key, T > &other)
 Assigns other to this hash and returns a reference to this hash. More...
 
bool operator== (const QHash< Key, T > &other) const
 Returns true if other is equal to this hash; otherwise returns false. More...
 
T & operator[] (const Key &key)
 Returns the value associated with the key as a modifiable reference. More...
 
const T operator[] (const Key &key) const
 Same as value(). More...
 
 QHash ()
 Constructs an empty hash. More...
 
 QHash (const QHash< Key, T > &other)
 Constructs a copy of other. More...
 
int remove (const Key &key)
 Removes all the items that have the key from the hash. More...
 
void reserve (int size)
 Ensures that the QHash's internal hash table consists of at least size buckets. More...
 
void setSharable (bool sharable)
 
int size () const
 Returns the number of items in the hash. More...
 
void squeeze ()
 Reduces the size of the QHash's internal hash table to save memory. More...
 
void swap (QHash< Key, T > &other)
 Swaps hash other with this hash. More...
 
take (const Key &key)
 Removes the item with the key from the hash and returns the value associated with it. More...
 
QList< Key > uniqueKeys () const
 Returns a list containing all the keys in the map. More...
 
QHash< Key, T > & unite (const QHash< Key, T > &other)
 Inserts all the items in the other hash into this hash. More...
 
const T value (const Key &key) const
 Returns the value associated with the key. More...
 
const T value (const Key &key, const T &defaultValue) const
 If the hash contains no item with the given key, the function returns defaultValue. More...
 
QList< T > values () const
 Returns a list containing all the values in the hash, in an arbitrary order. More...
 
QList< T > values (const Key &key) const
 Returns a list of all the values associated with the key, from the most recently inserted to the least recently inserted. More...
 
 ~QHash ()
 Destroys the hash. More...
 

Private Types

typedef QHashDummyNode< Key, T > DummyNode
 
typedef QHashNode< Key, T > Node
 

Private Functions

NodecreateNode (uint h, const Key &key, const T &value, Node **nextNode)
 
void deleteNode (Node *node)
 
void detach_helper ()
 
Node ** findNode (const Key &key, uint *hp=0) const
 
void freeData (QHashData *d)
 

Static Private Functions

static int alignOfDummyNode ()
 
static int alignOfNode ()
 
static Nodeconcrete (QHashData::Node *node)
 
static void deleteNode2 (QHashData::Node *node)
 
static void duplicateNode (QHashData::Node *originalNode, void *newNode)
 

Properties

union {
   QHashData *   d
 
   QHashNode< Key, T > *   e
 
}; 
 

Friends

class const_iterator
 
class iterator
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &out, const QHash< Key, T > &hash)
 Writes the hash hash to stream out. More...
 
QDataStreamoperator>> (QDataStream &in, QHash< Key, T > &hash)
 Reads a hash from stream in into hash. More...
 
uint qHash (const QPair< T1, T2 > &key)
 Returns the hash value for the key. More...
 
uint qHash (char key)
 Returns the hash value for the key. More...
 
uint qHash (uchar key)
 Returns the hash value for the key. More...
 
uint qHash (signed char key)
 Returns the hash value for the key. More...
 
uint qHash (ushort key)
 Returns the hash value for the key. More...
 
uint qHash (short key)
 Returns the hash value for the key. More...
 
uint qHash (uint key)
 Returns the hash value for the key. More...
 
uint qHash (int key)
 Returns the hash value for the key. More...
 
uint qHash (ulong key)
 Returns the hash value for the key. More...
 
uint qHash (long key)
 Returns the hash value for the key. More...
 
uint qHash (quint64 key)
 Returns the hash value for the key. More...
 
uint qHash (qint64 key)
 Returns the hash value for the key. More...
 
uint qHash (QChar key)
 Returns the hash value for the key. More...
 
uint qHash (const QBitArray &key)
 
uint qHash (const QString &key)
 Returns the hash value for the key. More...
 
uint qHash (const T *key)
 
uint qHash (const QXmlNodeModelIndex &index)
 Computes a hash key from the QXmlNodeModelIndex index, and returns it. More...
 

Detailed Description

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

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

Note
This class or function is reentrant.

QHash<Key, T> is one of Qt's generic 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:

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

hash.insert("twelve", 12);

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

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

If there is no item with the specified key in the hash, these functions return a 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:

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

In general, we recommend that you use contains() and value() rather than operator[]() for looking up a key in a hash. The reason is that operator[]() silently inserts an item into the hash if no item exists with the same key (unless the hash is const). For example, the following code snippet will create 1000 items in memory:

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

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

If you want to navigate through all the (key, value) pairs stored in a QHash, you can use an iterator. QHash provides both Java-style iterators (QHashIterator and QMutableHashIterator) and 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 << i.key() << ": " << i.value() << endl;
}

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

while (i != hash.constEnd()) {
cout << i.key() << ": " << i.value() << endl;
++i;
}

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

Normally, 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

However, you can store multiple values per key by using insertMulti() instead of insert() (or using the convenience subclass QMultiHash). 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 (int i = 0; i < values.size(); ++i)
cout << values.at(i) << endl;

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 iterator for the first item with a key and iterate from there:

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

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

...
foreach (int value, 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 assignable data types. You cannot, for example, store a QWidget as a value; instead, store a QWidget *. In addition, QHash's key type must provide operator==(), and there must also be a global qHash() function that returns a hash value for an argument of the key's type.

Here's a list of the C++ and Qt types that can serve as keys in a QHash: any integer type (char, unsigned long, etc.), any pointer type, QChar, QString, and QByteArray. For all of these, the <QHash> header defines a qHash() function that computes an adequate hash value. If you want to use other types as the key, make sure that you provide operator==() and a qHash() implementation.

Example:

#ifndef EMPLOYEE_H
#define EMPLOYEE_H
class Employee
{
public:
Employee() {}
Employee(const QString &name, const 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 uint qHash(const Employee &key)
{
return qHash(key.name()) ^ key.dateOfBirth().day();
}
#endif // EMPLOYEE_H

The qHash() function computes a numeric value based on a key. It can use any algorithm imaginable, as long as it always returns the same value if given the same argument. In other words, if e1 == e2, then qHash(e1) == qHash(e2) must hold as well. However, to obtain good performance, the qHash() function should attempt to return different hash values for different keys to the largest extent possible.

In the example above, we've relied on Qt's global qHash(const QString &) to give us a hash value for the employee's name, and XOR'ed this with the day they were born to help produce unique hashes for people with the same name.

Internally, QHash uses a hash table to perform lookups. Unlike Qt 3's QDict class, which needed to be initialized with a prime number, QHash's hash table automatically grows and shrinks to provide fast lookups without wasting too much memory. You can still control the size of the hash table by calling 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.

See also
QHashIterator, QMutableHashIterator, QMap, QSet

Definition at line 66 of file qdatastream.h.

Typedefs

◆ ConstIterator

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

Qt-style synonym for QHash::const_iterator.

Definition at line 474 of file qhash.h.

◆ difference_type

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

Typedef for ptrdiff_t.

Provided for STL compatibility.

Definition at line 486 of file qhash.h.

◆ DummyNode

template<class Key, class T>
typedef QHashDummyNode<Key, T> QHash< Key, T >::DummyNode
private

Definition at line 260 of file qhash.h.

◆ Iterator

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

Qt-style synonym for QHash::iterator.

Definition at line 473 of file qhash.h.

◆ key_type

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

Typedef for Key.

Provided for STL compatibility.

Definition at line 485 of file qhash.h.

◆ mapped_type

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

Typedef for T.

Provided for STL compatibility.

Definition at line 484 of file qhash.h.

◆ Node

template<class Key, class T>
typedef QHashNode<Key, T> QHash< Key, T >::Node
private

Definition at line 261 of file qhash.h.

◆ size_type

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

Typedef for int.

Provided for STL compatibility.

Definition at line 487 of file qhash.h.

Constructors and Destructors

◆ QHash() [1/2]

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

Constructs an empty hash.

See also
clear()

Definition at line 281 of file qhash.h.

281 : d(&QHashData::shared_null) { d->ref.ref(); }
QBasicAtomicInt ref
Definition: qhash.h:121
QHashData * d
Definition: qhash.h:264
static QHashData shared_null
Definition: qhash.h:151

◆ QHash() [2/2]

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

Constructs a copy of other.

This operation occurs in constant time, because QHash is 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 linear time.

See also
operator=()

Definition at line 282 of file qhash.h.

282 : d(other.d) { d->ref.ref(); if (!d->sharable) detach(); }
QBasicAtomicInt ref
Definition: qhash.h:121
QHashData * d
Definition: qhash.h:264
uint sharable
Definition: qhash.h:127
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303

◆ ~QHash()

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

283 { if (!d->ref.deref()) freeData(d); }
QBasicAtomicInt ref
Definition: qhash.h:121
QHashData * d
Definition: qhash.h:264
void freeData(QHashData *d)
Definition: qhash.h:568

Functions

◆ alignOfDummyNode()

template<class Key, class T>
static int QHash< Key, T >::alignOfDummyNode ( )
inlinestaticprivate

Definition at line 277 of file qhash.h.

277 { return 0; }

◆ alignOfNode()

template<class Key, class T>
static int QHash< Key, T >::alignOfNode ( )
inlinestaticprivate

Definition at line 276 of file qhash.h.

276 { return 0; }

◆ begin() [1/2]

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

Returns an STL-style iterator pointing to the first item in the hash.

See also
constBegin(), end()

Definition at line 464 of file qhash.h.

Referenced by QScriptDebuggerCodeWidgetPrivate::_q_onScriptsChanged(), QPMCache::allPixmaps(), QStateMachinePrivate::applyProperties(), QSet< typename TokenLookupClass::NodeName >::begin(), QGLGlyphCache::cacheGlyphs(), QGLGlyphCache::cleanCache(), QSqlDatabasePrivate::cleanConnections(), QGestureManager::cleanupCachedGestures(), QNetworkAccessCache::clear(), QDeclarativeTimeLine::clear(), QDeclarativePropertyCache::clear(), QDeclarativeTypeLoader::clearCache(), QDeclarativeCompiler::compileTree(), QDeclarativePropertyCache::copy(), QDeclarativeEnginePrivate::createCache(), QPatternist::Template::createContext(), QDeclarativeVisualDataModelPrivate::createMetaData(), ModelNode::dump(), QDeclarativeVisualDataModelPrivate::ensureRoles(), QDeclarativeIntegerCache::findId(), QPMCache::flushDetachedPixmaps(), QAxScriptManager::functions(), QDeclarativeCompiler::genContextCache(), QGraphicsScenePrivate::gestureEventHandler(), QDeclarativeGridView::itemsMoved(), QDeclarativeListView::itemsMoved(), MetaObjectGenerator::metaObject(), QDBusConnectionPrivate::objectDestroyed(), operator<<(), QTextureGlyphCache::populate(), QDeclarativeImports::populateCache(), qDBusRemoveTimeout(), qPRCleanup(), QDeclarativeDebugConnectionPrivate::readyRead(), QDeclarativeTimeLine::remove(), QGraphicsScenePrivate::removeItemHelper(), QFSEventsFileSystemWatcherEngine::removePaths(), QDialogButtonBoxPrivate::retranslateStrings(), QAxScriptManager::scriptForFunction(), QAxScriptManager::scriptNames(), QTextControl::setExtraSelections(), QEventDispatcherMac::unregisterTimers(), ModelNode::updateListIndexes(), QDeclarativeGridViewPrivate::updateUnrequestedIndexes(), QDeclarativeListViewPrivate::updateUnrequestedIndexes(), QDeclarativeGridViewPrivate::updateUnrequestedPositions(), QDeclarativeListViewPrivate::updateUnrequestedPositions(), QDeclarativeWorkerScriptEnginePrivate::variantToScriptValue(), QPdfEnginePrivate::writeFonts(), QDeclarativeDataLoader::~QDeclarativeDataLoader(), QDeclarativeDebugConnection::~QDeclarativeDebugConnection(), QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate(), QDeclarativeTimeLine::~QDeclarativeTimeLine(), QEventDispatcherMac::~QEventDispatcherMac(), QPaintBufferResource::~QPaintBufferResource(), and QPrintDialogPrivate::~QPrintDialogPrivate().

464 { detach(); return iterator(d->firstNode()); }
Node * firstNode()
Definition: qhash.h:181
QHashData * d
Definition: qhash.h:264
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303
friend class iterator
Definition: qhash.h:393

◆ begin() [2/2]

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

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

465 { return const_iterator(d->firstNode()); }
Node * firstNode()
Definition: qhash.h:181
QHashData * d
Definition: qhash.h:264
friend class const_iterator
Definition: qhash.h:461

◆ capacity()

template<class Key, class T>
int QHash< Key, T >::capacity ( ) const
inline

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

Referenced by QSet< typename TokenLookupClass::NodeName >::capacity().

299 { return d->numBuckets; }
QHashData * d
Definition: qhash.h:264
int numBuckets
Definition: qhash.h:126

◆ clear()

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

Removes all items from the hash.

See also
remove()

Definition at line 574 of file qhash.h.

Referenced by QGraphicsAnchorLayoutPrivate::calculateGraphs(), QStateMachinePrivate::cancelAllDelayedEvents(), QGLGlyphCache::cleanCache(), QSqlDatabasePrivate::cleanConnections(), cleanup_cmaps(), QmlJSDebugger::LiveSelectionIndicator::clear(), QDeclarativeIntegerCache::clear(), QProcessEnvironment::clear(), QSet< typename TokenLookupClass::NodeName >::clear(), QDeclarativeTypeNameCache::clear(), QNetworkAccessCache::clear(), QDeclarativeTimeLine::clear(), QDeclarativePropertyCache::clear(), ModelNode::clear(), QDeclarativeTypeLoader::clearCache(), QHeaderViewPrivate::clearCascadingSections(), QRelation::clearDictionary(), QmlJSDebugger::AbstractViewInspector::handleMessage(), QGtkStylePrivate::initGtkWidgets(), QTextDocumentLayoutPrivate::layoutTable(), operator>>(), QPatternist::XsdSchemaParser::parse(), QPatternist::NamespaceSupport::popContext(), QSvgIconEngine::read(), QStyleSheetStyle::repolish(), QJSDebuggerAgent::setBreakpoints(), QApplication::setFont(), QApplicationPrivate::setPalette_helper(), QTextDocumentWithImageResources::setText(), QIconLoader::setThemeSearchPath(), QPatternist::ParserContext::templateWithParametersHandled(), QStyleSheetStyle::unpolish(), unregWinClasses(), QPdfEnginePrivate::writeFonts(), QAxBasePrivate::~QAxBasePrivate(), QDBusConnectionManager::~QDBusConnectionManager(), QEventDispatcherMac::~QEventDispatcherMac(), and QGestureManager::~QGestureManager().

575 {
576  *this = QHash<Key,T>();
577 }
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66

◆ concrete()

template<class Key, class T>
static Node* QHash< Key, T >::concrete ( QHashData::Node node)
inlinestaticprivate

Definition at line 268 of file qhash.h.

268  {
269  return reinterpret_cast<Node *>(node);
270  }

◆ constBegin()

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

Returns a const STL-style iterator pointing to the first item in the hash.

See also
begin(), constEnd()

Definition at line 466 of file qhash.h.

Referenced by _q_dupEnvironment(), QStateMachinePrivate::applyProperties(), QPatternist::DelegatingNamespaceResolver::bindings(), QStateMachinePrivate::cancelAllDelayedEvents(), cleanup_cmaps(), QGtkStylePrivate::cleanupGtkWidgets(), QPatternist::TemplateInvoker::compress(), Graph< Vertex, EdgeData >::const_iterator::const_iterator(), QSet< typename TokenLookupClass::NodeName >::constBegin(), QPatternist::ConstructorFunctionsFactory::ConstructorFunctionsFactory(), QPSPrintEnginePrivate::emitPages(), QPatternist::TemplateInvoker::expectedOperandTypes(), QPSPrintEnginePrivate::flushPage(), QApplication::font(), QPatternist::FunctionFactory::hasSignature(), QMacPrintEnginePrivate::initialize(), QProcessEnvironmentPrivate::insert(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QSimplexConstraint::isSatisfied(), QProcessEnvironmentPrivate::keys(), QScriptEnginePrivate::mark(), QScript::QObjectDelegate::markChildren(), Graph< Vertex, EdgeData >::const_iterator::operator++(), operator<<(), QApplication::palette(), QPatternist::PatternPlatform::parseFlags(), QPatternist::NamespaceSupport::prefix(), qt_create_commandline(), QInotifyFileSystemWatcherEngine::readFromInotify(), QEventDispatcherMac::registeredTimers(), QStateMachinePrivate::restorablesToPropertyList(), QDomDocumentTypePrivate::save(), QDomElementPrivate::save(), QSimplex::setConstraints(), QSimplex::simplifyConstraints(), QSimplex::solver(), QFont::substitutions(), QPatternist::TemplateInvoker::TemplateInvoker(), QProcessEnvironmentPrivate::toList(), QSimplexConstraint::toString(), QGraphicsScenePrivate::touchEventHandler(), QApplicationPrivate::translateRawTouchEvent(), QPatternist::CallTemplate::typeCheck(), QHash< QExplicitlySharedDataPointer, QHash >::unite(), QStateMachinePrivate::unregisterEventTransition(), unregWinClasses(), QAxScriptManager::updateScript(), QDBusConnectionManager::~QDBusConnectionManager(), and QScriptEnginePrivate::~QScriptEnginePrivate().

466 { return const_iterator(d->firstNode()); }
Node * firstNode()
Definition: qhash.h:181
QHashData * d
Definition: qhash.h:264
friend class const_iterator
Definition: qhash.h:461

◆ constEnd()

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

Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash.

See also
constBegin(), end()

Definition at line 469 of file qhash.h.

Referenced by _q_dupEnvironment(), QStateMachinePrivate::applyProperties(), QStyleSheetStyleSelector::attribute(), QPatternist::DelegatingNamespaceResolver::bindings(), QGLGlyphCache::cacheGlyphs(), QStateMachinePrivate::cancelAllDelayedEvents(), cleanup_cmaps(), QGtkStylePrivate::cleanupGtkWidgets(), QCoreGraphicsPaintEngine::cleanUpMacColorSpaces(), QPatternist::TemplateInvoker::compress(), QDBusConnectionPrivate::connectRelay(), QDBusConnectionPrivate::connectSignal(), Graph< Vertex, EdgeData >::const_iterator::const_iterator(), QSet< typename TokenLookupClass::NodeName >::constEnd(), QPatternist::ConstructorFunctionsFactory::ConstructorFunctionsFactory(), QMultiHash< const QGLContext *, GLProgram >::contains(), QPSPrintEnginePrivate::emitPages(), QPatternist::TemplateInvoker::expectedOperandTypes(), QDeclarativeJS::Ecma::RegExp::flagFromChar(), QPSPrintEnginePrivate::flushPage(), QApplication::font(), QDBusConnectionPrivate::getNameOwner(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QDBusConnectionPrivate::handleSignal(), QPatternist::FunctionFactory::hasSignature(), QStyleSheetStyle::hasStyleRule(), QSortFilterProxyModelPrivate::index_to_iterator(), QMacPrintEnginePrivate::initialize(), QApplicationPrivate::initializeWidgetPaletteHash(), QProcessEnvironmentPrivate::insert(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QSimplexConstraint::isSatisfied(), QProcessEnvironmentPrivate::keys(), QScriptEnginePrivate::mark(), QScript::QObjectDelegate::markChildren(), QDesktopServices::openUrl(), Graph< Vertex, EdgeData >::const_iterator::operator++(), operator<<(), QApplication::palette(), QPatternist::PatternPlatform::parseFlags(), QJSDebuggerAgentPrivate::positionChange(), QPatternist::NamespaceSupport::prefix(), QScript::QObjectDelegate::put(), QScriptEnginePrivate::qobjectData(), qPRCleanup(), qt_create_commandline(), qt_gl_choose_cmap(), QInotifyFileSystemWatcherEngine::readFromInotify(), QCache< QPixmapCache::Key, QPixmapCacheEntry >::relink(), QStyleSheetStyle::renderRule(), QStateMachinePrivate::restorablesToPropertyList(), QDomDocumentTypePrivate::save(), QDomElementPrivate::save(), QSimplex::setConstraints(), QSimplex::simplifyConstraints(), QDBusConnectionPrivate::socketRead(), QDBusConnectionPrivate::socketWrite(), QSimplex::solver(), QAuServerMac::stop(), QStyleSheetStyle::styleRules(), QFont::substitute(), QFont::substitutions(), QPatternist::TemplateInvoker::TemplateInvoker(), QProcessEnvironmentPrivate::toList(), QSimplexConstraint::toString(), QGraphicsScenePrivate::touchEventHandler(), QApplicationPrivate::translateRawTouchEvent(), QPatternist::CallTemplate::typeCheck(), QHash< QExplicitlySharedDataPointer, QHash >::unite(), QStateMachinePrivate::unregisterEventTransition(), unregWinClasses(), QAxScriptManager::updateScript(), QProcessEnvironment::value(), QDBusConnectionManager::~QDBusConnectionManager(), and QScriptEnginePrivate::~QScriptEnginePrivate().

469 { return const_iterator(e); }
QHashNode< Key, T > * e
Definition: qhash.h:265
friend class const_iterator
Definition: qhash.h:461

◆ constFind()

template<class Key, class T >
Q_INLINE_TEMPLATE QHash< Key, T >::const_iterator QHash< Key, T >::constFind ( const Key &  key) const

◆ contains()

template<class Key, class T >
Q_INLINE_TEMPLATE bool QHash< Key, T >::contains ( const Key &  key) const

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

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

Definition at line 872 of file qhash.h.

Referenced by _q_dupEnvironment(), QDeclarativeIntegerCache::add(), QDeclarativeTypeNameCache::add(), QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(), QPatternist::XsdSchema::addAnonymousType(), QSqlDatabasePrivate::addDatabase(), QPatternist::XsdSchemaParser::addFacet(), QDeclarativeCompiler::addId(), QAxScriptManager::addObject(), QWindowsFileSystemWatcherEngine::addPaths(), QWSPropertyManager::addProperty(), QPatternist::XsdValidatingInstanceReader::addSchema(), FlatListModel::addValue(), QDeclarativePropertyCache::append(), QStateMachinePrivate::applyProperties(), QPatternist::XsdInstanceReader::attribute(), QDeclarativeCompiler::buildComponent(), QDeclarativeCompiler::buildIdProperty(), callback(), QPatternist::XsdSchemaChecker::checkAttributeUseConstraints(), QPatternist::XsdSchemaChecker::checkConstrainingFacets(), QPatternist::XsdTypeChecker::checkConstrainingFacetsBinary(), QPatternist::XsdTypeChecker::checkConstrainingFacetsBoolean(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDateTime(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDecimal(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDouble(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDuration(), QPatternist::XsdTypeChecker::checkConstrainingFacetsList(), QPatternist::XsdTypeChecker::checkConstrainingFacetsNotation(), QPatternist::XsdTypeChecker::checkConstrainingFacetsQName(), QPatternist::XsdTypeChecker::checkConstrainingFacetsSignedInteger(), QPatternist::XsdTypeChecker::checkConstrainingFacetsString(), QPatternist::XsdTypeChecker::checkConstrainingFacetsUnion(), QPatternist::XsdTypeChecker::checkConstrainingFacetsUnsignedInteger(), QPatternist::XsdSchemaChecker::checkElementDuplicates(), QGtkStylePrivate::cleanupGtkWidgets(), QPatternist::ColorOutput::colorify(), QPatternist::ColoringMessageHandler::colorifyDescription(), QDeclarativeCompiler::compileAlias(), QDeclarativeCompiler::compileTree(), EGLNullWSScreen::connect(), QAxBase::connectNotify(), QProcessEnvironment::contains(), QSet< typename TokenLookupClass::NodeName >::contains(), QCache< QPixmapCache::Key, QPixmapCacheEntry >::contains(), QPatternist::Template::createContext(), QPatternist::XsdSchemaTypesFactory::createSchemaType(), QEventDispatcherWin32Private::doWsaAsyncSelect(), QSvgFont::draw(), QDeclarativePath::endpoint(), QPatternist::TypeAvailableFN::evaluateSingleton(), familyNameFromPostScriptName(), QNetworkAccessHttpBackend::fetchCacheMetaData(), QGestureManager::filterEvent(), QRegExpEngine::getEscape(), QGraphicsAnchorLayoutPrivate::getGraphParts(), QSharedNetworkSessionManager::getSession(), QApplicationPrivate::globalEventProcessor(), QTextLine::glyphs(), QStateMachinePrivate::handleFilteredEvent(), QScriptDebuggerPrivate::handleResponse(), QPatternist::XsdInstanceReader::hasAttribute(), hasDuplicatedElementsInternal(), QNetworkAccessCache::hasEntry(), QBBEngine::hasIdentifier(), QWSPropertyManager::hasProperty(), QRenderRule::hasStyleHint(), QGtkStylePrivate::initGtkWidgets(), QDeclarativePath::interpolate(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QPatternist::XsdSchemaHelper::isValidAttributeUsesRestriction(), launchWebBrowser(), QNetworkAccessHttpBackend::loadFromCacheIfAllowed(), QFSFileEnginePrivate::longFileName(), QNetworkReplyImplPrivate::metaDataChanged(), QPatternist::XsdTypeChecker::normalizedValue(), QAxMetaObject::numParameter(), QMultiHash< const QGLContext *, GLProgram >::operator+(), QAxMetaObject::paramType(), QXmlStreamReaderPrivate::parse(), parseServerList(), QStyleSheetStyle::polish(), QTextureGlyphCache::populate(), QPatternist::XsdStateMachine< XsdSchemaToken::NodeName >::proceed(), QPatternist::NamespaceSupport::processName(), QDeclarativePath::processPath(), qt_create_commandline(), qt_mac_handleTabletEvent(), QtWndProc(), QPatternist::XSLTTokenizer::readAlternativeAttribute(), QInotifyFileSystemWatcherEngine::readFromInotify(), QDeclarativeMetaType::registerCustomStringConverter(), QEventDispatcherWin32::registerSocketNotifier(), QFreetypeFace::release(), QSqlDatabasePrivate::removeDatabase(), QDeclarativeWatcher::removeWatch(), QNetworkAccessHttpBackend::replyDownloadMetaData(), QPatternist::XsdSchemaResolver::resolveAttributeInheritance(), QPatternist::XsdSchemaResolver::resolveEnumerationFacetValues(), QHeaderViewPrivate::saveCascadingSectionSize(), QSqlRelationalTableModel::setData(), QmlJSDebugger::LiveSelectionIndicator::setItems(), ModelNode::setObjectValue(), QSimplex::simplifyConstraints(), QPatternist::XsdSchemaChecker::sourceLocation(), QPatternist::AccelTree::sourceLocation(), QPatternist::XsdSchemaResolver::sourceLocation(), FlatListModel::toString(), QFSFileEnginePrivate::unmap(), QGestureManager::unregisterGestureRecognizer(), QStyleSheetStyle::unsetPalette(), QMenuPrivate::updateActionRects(), and QPatternist::XsdValidatingInstanceReader::validateElementComplexType().

873 {
874  return *findNode(akey) != e;
875 }
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
QHashNode< Key, T > * e
Definition: qhash.h:265

◆ count() [1/2]

template<class Key, class T >
Q_OUTOFLINE_TEMPLATE int QHash< Key, T >::count ( const Key &  key) const

◆ count() [2/2]

template<class Key, class T>
int QHash< Key, T >::count ( ) const
inline

Same as size().

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

Referenced by QMultiHash< const QGLContext *, GLProgram >::operator+().

475 { return d->size; }
int size
Definition: qhash.h:122
QHashData * d
Definition: qhash.h:264

◆ createNode()

template<class Key, class T>
Q_INLINE_TEMPLATE QHash< Key, T >::Node * QHash< Key, T >::createNode ( uint  h,
const Key &  key,
const T &  value,
Node **  nextNode 
)
private

Definition at line 538 of file qhash.h.

539 {
540  Node *node;
541 
542  if (QTypeInfo<T>::isDummy) {
543  node = reinterpret_cast<Node *>(new (d->allocateNode(alignOfDummyNode())) DummyNode(akey));
544  } else {
545  node = new (d->allocateNode(alignOfNode())) Node(akey, avalue);
546  }
547 
548  node->h = ah;
549  node->next = *anextNode;
550  *anextNode = node;
551  ++d->size;
552  return node;
553 }
static int alignOfNode()
Definition: qhash.h:276
void * allocateNode()
Definition: qhash.cpp:172
int size
Definition: qhash.h:122
QHashData * d
Definition: qhash.h:264
QHashDummyNode< Key, T > DummyNode
Definition: qhash.h:260
static int alignOfDummyNode()
Definition: qhash.h:277
QHashNode< Key, T > Node
Definition: qhash.h:261

◆ deleteNode()

template<class Key , class T >
Q_INLINE_TEMPLATE void QHash< Key, T >::deleteNode ( Node node)
private

Definition at line 509 of file qhash.h.

510 {
511  deleteNode2(reinterpret_cast<QHashData::Node*>(node));
512  d->freeNode(node);
513 }
QHashData * d
Definition: qhash.h:264
static void deleteNode2(QHashData::Node *node)
Definition: qhash.h:516
void freeNode(void *node)
Definition: qhash.cpp:184

◆ deleteNode2()

template<class Key , class T >
Q_INLINE_TEMPLATE void QHash< Key, T >::deleteNode2 ( QHashData::Node node)
staticprivate

Definition at line 516 of file qhash.h.

517 {
518 #ifdef Q_CC_BOR
519  concrete(node)->~QHashNode<Key, T>();
520 #else
521  concrete(node)->~Node();
522 #endif
523 }
static Node * concrete(QHashData::Node *node)
Definition: qhash.h:268

◆ detach()

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

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

Warning
This function is not part of the public interface.
See also
isDetached()

Definition at line 303 of file qhash.h.

Referenced by QSet< typename TokenLookupClass::NodeName >::detach().

303 { if (d->ref != 1) detach_helper(); }
QBasicAtomicInt ref
Definition: qhash.h:121
void detach_helper()
Definition: qhash.h:580
QHashData * d
Definition: qhash.h:264

◆ detach_helper()

template<class Key , class T >
Q_OUTOFLINE_TEMPLATE void QHash< Key, T >::detach_helper ( )
private

Definition at line 580 of file qhash.h.

581 {
583  QTypeInfo<T>::isDummy ? sizeof(DummyNode) : sizeof(Node),
585  if (!d->ref.deref())
586  freeData(d);
587  d = x;
588 }
QBasicAtomicInt ref
Definition: qhash.h:121
static int alignOfNode()
Definition: qhash.h:276
QHashData * detach_helper2(void(*node_duplicate)(Node *, void *), void(*node_delete)(Node *), int nodeSize, int nodeAlign)
Definition: qhash.cpp:197
QHashData * d
Definition: qhash.h:264
QHashDummyNode< Key, T > DummyNode
Definition: qhash.h:260
static void deleteNode2(QHashData::Node *node)
Definition: qhash.h:516
static int alignOfDummyNode()
Definition: qhash.h:277
static void duplicateNode(QHashData::Node *originalNode, void *newNode)
Definition: qhash.h:526
void freeData(QHashData *d)
Definition: qhash.h:568

◆ duplicateNode()

template<class Key , class T >
Q_INLINE_TEMPLATE void QHash< Key, T >::duplicateNode ( QHashData::Node originalNode,
void *  newNode 
)
staticprivate

Definition at line 526 of file qhash.h.

527 {
528  Node *concreteNode = concrete(node);
529  if (QTypeInfo<T>::isDummy) {
530  (void) new (newNode) DummyNode(concreteNode->key);
531  } else {
532  (void) new (newNode) Node(concreteNode->key, concreteNode->value);
533  }
534 }
static Node * concrete(QHashData::Node *node)
Definition: qhash.h:268
QHashDummyNode< Key, T > DummyNode
Definition: qhash.h:260
QHashNode< Key, T > Node
Definition: qhash.h:261

◆ empty()

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

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

489 { return isEmpty(); }
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297

◆ end() [1/2]

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

Returns an STL-style iterator pointing to the imaginary item after the last item in the hash.

See also
begin(), constEnd()

Definition at line 467 of file qhash.h.

Referenced by QStateMachinePrivate::_q_animationFinished(), QScriptEnginePrivate::_q_objectDestroyed(), QScriptDebuggerCodeWidgetPrivate::_q_onScriptsChanged(), QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QDeclarativeTypeLoader::absoluteFilePath(), QDeclarativeFastProperties::accessorIndexForProperty(), QDeclarativeTimeLinePrivate::add(), QDeclarativeContextData::addImportedScript(), FlatListModel::addValue(), QPMCache::allPixmaps(), QStateMachinePrivate::applyProperties(), QGLGlyphCache::cacheGlyphs(), callback(), QMetaObject::changeGuard(), QGLGlyphCache::cleanCache(), QSqlDatabasePrivate::cleanConnections(), QGestureManager::cleanupCachedGestures(), QNetworkAccessCache::clear(), QDeclarativeTimeLine::clear(), QDeclarativePropertyCache::clear(), QDeclarativeTypeLoader::clearCache(), QObjectPrivate::clearGuards(), QDeclarativeCompiler::compileTree(), QDBusConnectionPrivate::connectSignal(), QDeclarativePropertyCache::copy(), QPersistentModelIndexData::create(), QDeclarativeEnginePrivate::createCache(), QPatternist::Template::createContext(), QDeclarativeVisualDataModelPrivate::createMetaData(), NestedListModel::data(), QScript::QObjectDelegate::deleteProperty(), QDBusConnectionPrivate::disconnectRelay(), QDBusConnectionPrivate::disconnectSignal(), QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations(), ModelNode::dump(), QSet< typename TokenLookupClass::NodeName >::end(), QDeclarativeVisualDataModelPrivate::ensureRoles(), QDeclarativeIntegerCache::findId(), QPMCache::flushDetachedPixmaps(), QGLGlyphCache::fontEngineDestroyed(), QAxScriptManager::functions(), QDeclarativeCompiler::genContextCache(), QGraphicsScenePrivate::gestureEventHandler(), QWSPropertyManager::getProperty(), QTextFormatCollection::hasFormatCached(), QTextFormatCollection::indexForFormat(), QDeclarativeVisualDataModelDataMetaObject::initialValue(), QPaintBufferResource::insert(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QDeclarativeMetaType::isModule(), QNetworkAccessCache::linkEntry(), QDeclarativeEnginePrivate::listType(), QDeclarativePixmap::load(), QTextDocumentWithImageResources::loadResource(), QReadWriteLock::lockForRead(), MetaObjectGenerator::metaObject(), QDBusConnectionPrivate::objectDestroyed(), Graph< Vertex, EdgeData >::const_iterator::operator!=(), operator<<(), QHash< QExplicitlySharedDataPointer, QHash >::operator==(), QDeclarativeOpenMetaObject::operator[](), QTextureGlyphCache::populate(), QDeclarativeImports::populateCache(), QDeclarativeVisualDataModelData::propForRole(), qDBusRealToggleWatch(), qDBusRemoveTimeout(), qDBusRemoveWatch(), QDeclarativeType::QDeclarativeType(), QDeclarativeTypeLoader::qmlDirParser(), QDeclarativeMetaType::qmlType(), QDeclarativeDebugConnectionPrivate::readyRead(), QDnotifyFileSystemWatcherEngine::refresh(), QDeclarativeBindingCompilerPrivate::registerString(), registerType(), QNetworkAccessCache::releaseEntry(), QDeclarativeTimeLine::remove(), QPaintBufferResource::remove(), QNetworkAccessCache::removeEntry(), QMetaObject::removeGuard(), QGraphicsScenePrivate::removeItemHelper(), QFSEventsFileSystemWatcherEngine::removePaths(), QWSPropertyManager::removeProperty(), QGtkStylePrivate::removeWidgetFromMap(), QNetworkAccessCache::requestEntry(), QNetworkAccessCache::requestEntryNow(), QDialogButtonBoxPrivate::retranslateStrings(), QAxScriptManager::scriptForFunction(), QAxScriptManager::scriptNames(), QDBusConnectionPrivate::serviceOwnerChangedNoLock(), QTextControl::setExtraSelections(), QWSPropertyManager::setProperty(), FlatListModel::setProperty(), ModelNode::setProperty(), QDeclarativeOpenMetaObject::setValue(), QDeclarativeBindingCompilerPrivate::subscriptionIndex(), QDeclarativeTimeLine::sync(), QReadWriteLock::tryLockForRead(), QNetworkAccessCache::unlinkEntry(), QReadWriteLock::unlock(), ModelNode::updateListIndexes(), QDeclarativeGridViewPrivate::updateUnrequestedIndexes(), QDeclarativeListViewPrivate::updateUnrequestedIndexes(), QDeclarativeGridViewPrivate::updateUnrequestedPositions(), QDeclarativeListViewPrivate::updateUnrequestedPositions(), QDeclarativeOpenMetaObject::value(), QPaintBufferResource::value(), QDeclarativeWorkerScriptEnginePrivate::variantToScriptValue(), QPdfEnginePrivate::writeFonts(), QDeclarativeDataLoader::~QDeclarativeDataLoader(), QDeclarativeDebugConnection::~QDeclarativeDebugConnection(), QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate(), QDeclarativeTimeLine::~QDeclarativeTimeLine(), QPaintBufferResource::~QPaintBufferResource(), and QPrintDialogPrivate::~QPrintDialogPrivate().

467 { detach(); return iterator(e); }
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303
QHashNode< Key, T > * e
Definition: qhash.h:265
friend class iterator
Definition: qhash.h:393

◆ end() [2/2]

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

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

468 { return const_iterator(e); }
QHashNode< Key, T > * e
Definition: qhash.h:265
friend class const_iterator
Definition: qhash.h:461

◆ erase()

template<class Key , class T >
Q_OUTOFLINE_TEMPLATE QHash< Key, T >::iterator QHash< Key, T >::erase ( iterator  pos)

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

Unlike remove() and take(), this function never causes QHash to rehash its internal data structure. This means that it can safely be called while iterating, and won't affect the order of items in the hash. For example:

...
QHash<QObject *, int>::iterator i = objectHash.find(obj);
while (i != objectHash.end() && i.key() == obj) {
if (i.value() == 0) {
i = objectHash.erase(i);
} else {
++i;
}
}
See also
remove(), take(), find()

Definition at line 827 of file qhash.h.

Referenced by QStateMachinePrivate::_q_animationFinished(), QScriptEnginePrivate::_q_objectDestroyed(), QScriptDebuggerCodeWidgetPrivate::_q_onScriptsChanged(), QStateMachinePrivate::applyProperties(), QMetaObject::changeGuard(), QObjectPrivate::clearGuards(), QScript::QObjectDelegate::deleteProperty(), QDBusConnectionPrivate::disconnectSignal(), QSet< typename TokenLookupClass::NodeName >::erase(), QPMCache::flushDetachedPixmaps(), qDBusRemoveTimeout(), qDBusRemoveWatch(), qPRCleanup(), QDeclarativeTimeLine::remove(), QPaintBufferResource::remove(), QMetaObject::removeGuard(), QGraphicsScenePrivate::removeItemHelper(), QFSEventsFileSystemWatcherEngine::removePaths(), QGtkStylePrivate::removeWidgetFromMap(), QWindowsFileSystemWatcherEngineThread::run(), QTextControl::setExtraSelections(), QReadWriteLock::unlock(), QEventDispatcherMac::unregisterTimers(), and QPrintDialogPrivate::~QPrintDialogPrivate().

828 {
829  if (it == iterator(e))
830  return it;
831 
832  iterator ret = it;
833  ++ret;
834 
835  Node *node = it;
836  Node **node_ptr = reinterpret_cast<Node **>(&d->buckets[node->h % d->numBuckets]);
837  while (*node_ptr != node)
838  node_ptr = &(*node_ptr)->next;
839  *node_ptr = node->next;
840  deleteNode(node);
841  --d->size;
842  return ret;
843 }
#define it(className, varName)
int size
Definition: qhash.h:122
QHashData * d
Definition: qhash.h:264
int numBuckets
Definition: qhash.h:126
Node ** buckets
Definition: qhash.h:120
QHashNode< Key, T > * e
Definition: qhash.h:265
void deleteNode(Node *node)
Definition: qhash.h:509
friend class iterator
Definition: qhash.h:393

◆ find() [1/2]

template<class Key, class T >
Q_INLINE_TEMPLATE QHash< Key, T >::iterator QHash< Key, T >::find ( const Key &  key)

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

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

If the hash contains multiple items with the key, this function returns an iterator that points to the most recently inserted value. The other values are accessible by incrementing the iterator. For example, here's some code that iterates over all the items with the same key:

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

Definition at line 865 of file qhash.h.

Referenced by QStateMachinePrivate::_q_animationFinished(), QScriptEnginePrivate::_q_objectDestroyed(), QDeclarativeTypeLoader::absoluteFilePath(), QDeclarativeFastProperties::accessorIndexForProperty(), QDeclarativeTimeLinePrivate::add(), QDeclarativeContextData::addImportedScript(), FlatListModel::addValue(), callback(), QDBusConnectionPrivate::connectSignal(), QPersistentModelIndexData::create(), NestedListModel::data(), QScript::QObjectDelegate::deleteProperty(), QDBusConnectionPrivate::disconnectSignal(), QSet< typename TokenLookupClass::NodeName >::find(), QGLGlyphCache::fontEngineDestroyed(), QWSPropertyManager::getProperty(), QDeclarativeVisualDataModelDataMetaObject::initialValue(), QPaintBufferResource::insert(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QDeclarativeMetaType::isModule(), QNetworkAccessCache::linkEntry(), QDeclarativeEnginePrivate::listType(), QDeclarativePixmap::load(), QTextDocumentWithImageResources::loadResource(), QReadWriteLock::lockForRead(), QMultiHash< const QGLContext *, GLProgram >::operator+(), operator<<(), QHash< QExplicitlySharedDataPointer, QHash >::operator==(), QDeclarativeOpenMetaObject::operator[](), QDeclarativeVisualDataModelData::propForRole(), QDeclarativeType::QDeclarativeType(), QDeclarativeTypeLoader::qmlDirParser(), QDeclarativeMetaType::qmlType(), QDeclarativeDebugConnectionPrivate::readyRead(), QDnotifyFileSystemWatcherEngine::refresh(), QDeclarativeBindingCompilerPrivate::registerString(), registerType(), QNetworkAccessCache::releaseEntry(), QCache< QPixmapCache::Key, QPixmapCacheEntry >::relink(), QDeclarativeTimeLine::remove(), QPaintBufferResource::remove(), QNetworkAccessCache::removeEntry(), QWSPropertyManager::removeProperty(), QGtkStylePrivate::removeWidgetFromMap(), QNetworkAccessCache::requestEntry(), QNetworkAccessCache::requestEntryNow(), QDBusConnectionPrivate::serviceOwnerChangedNoLock(), QTextControl::setExtraSelections(), QWSPropertyManager::setProperty(), FlatListModel::setProperty(), ModelNode::setProperty(), QDeclarativeOpenMetaObject::setValue(), QDeclarativeBindingCompilerPrivate::subscriptionIndex(), QDeclarativeTimeLine::sync(), QReadWriteLock::tryLockForRead(), QNetworkAccessCache::unlinkEntry(), QReadWriteLock::unlock(), QDeclarativeOpenMetaObject::value(), and QPaintBufferResource::value().

866 {
867  detach();
868  return iterator(*findNode(akey));
869 }
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303
friend class iterator
Definition: qhash.h:393

◆ find() [2/2]

template<class Key, class T >
Q_INLINE_TEMPLATE QHash< Key, T >::const_iterator QHash< Key, T >::find ( 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.

Definition at line 853 of file qhash.h.

854 {
855  return const_iterator(*findNode(akey));
856 }
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
friend class const_iterator
Definition: qhash.h:461

◆ findNode()

template<class Key, class T >
Q_OUTOFLINE_TEMPLATE QHash< Key, T >::Node ** QHash< Key, T >::findNode ( const Key &  key,
uint hp = 0 
) const
private

Definition at line 878 of file qhash.h.

880 {
881  Node **node;
882  uint h = qHash(akey);
883 
884  if (d->numBuckets) {
885  node = reinterpret_cast<Node **>(&d->buckets[h % d->numBuckets]);
886  Q_ASSERT(*node == e || (*node)->next);
887  while (*node != e && !(*node)->same_key(h, akey))
888  node = &(*node)->next;
889  } else {
890  node = const_cast<Node **>(reinterpret_cast<const Node * const *>(&e));
891  }
892  if (ahp)
893  *ahp = h;
894  return node;
895 }
uint qHash(const QPair< T1, T2 > &key)
Returns the hash value for the key.
Definition: qhash.h:105
QHashData * d
Definition: qhash.h:264
int numBuckets
Definition: qhash.h:126
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Node ** buckets
Definition: qhash.h:120
unsigned int uint
Definition: qglobal.h:996
QHashNode< Key, T > * e
Definition: qhash.h:265

◆ freeData()

template<class Key , class T >
Q_OUTOFLINE_TEMPLATE void QHash< Key, T >::freeData ( QHashData d)
private

Definition at line 568 of file qhash.h.

569 {
570  x->free_helper(deleteNode2);
571 }
static void deleteNode2(QHashData::Node *node)
Definition: qhash.h:516

◆ insert()

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

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

Definition at line 753 of file qhash.h.

Referenced by QDeclarativeVisualDataModel::_q_itemsInserted(), QDeclarativeVisualDataModel::_q_itemsMoved(), QDeclarativeVisualDataModel::_q_itemsRemoved(), QDeclarativeTypeLoader::absoluteFilePath(), QDeclarativeFastProperties::add(), QDeclarativeIntegerCache::add(), QDeclarativeTypeNameCache::add(), QDeclarativeTimeLinePrivate::add(), QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(), QPatternist::XsdSchema::addAnonymousType(), QPatternist::XsdSchemaParser::addAnonymousType(), QPatternist::XsdSchemaParser::addAttribute(), QPatternist::XsdSchemaParser::addAttributeGroup(), QPatternist::GenericNamespaceResolver::addBinding(), QPatternist::DelegatingNamespaceResolver::addBinding(), MetaObjectGenerator::addChangedSignal(), QPdfEnginePrivate::addConstantAlphaObject(), QSqlDatabasePrivate::addDatabase(), QPatternist::XsdSchemaParser::addElement(), QPatternist::XsdSchemaParser::addElementGroup(), QPatternist::XsdSchemaParser::addFacet(), QSvgIconEngine::addFile(), QPatternist::AbstractFunctionFactory::addFunction(), QSvgFont::addGlyph(), QDeclarativeCompiler::addId(), QPatternist::XsdSchemaParser::addIdentityConstraint(), QPdfEnginePrivate::addImage(), QDeclarativeContextData::addImportedScript(), QGraphicsAnchorLayoutPrivate::addInternalVertex(), QPatternist::GenericStaticContext::addLocation(), QSvgTinyDocument::addNamedNode(), QSvgTinyDocument::addNamedStyle(), QPatternist::XsdSchemaParser::addNotation(), QAxScriptManager::addObject(), QInotifyFileSystemWatcherEngine::addPaths(), QKqueueFileSystemWatcherEngine::addPaths(), QWindowsFileSystemWatcherEngine::addPaths(), QSvgIconEngine::addPixmap(), QPatternist::XsdValidatingInstanceReader::addSchema(), QSvgTinyDocument::addSvgFont(), QPatternist::XsdSchema::addType(), QPatternist::XsdSchemaParser::addType(), FlatListModel::addValue(), QGtkStylePrivate::addWidgetToMap(), QDirectFbInput::addWindow(), QDeclarativePropertyCache::append(), QStateMachinePrivate::applyProperties(), QPatternist::PullBridge::attributeItems(), QPatternist::PullBridge::attributes(), QGLGlyphCache::cacheGlyphs(), QScriptObjectSnapshot::capture(), QPatternist::XQueryTokenizer::charForReference(), QPatternist::XsdSchemaChecker::checkAttributeUseConstraints(), QPatternist::XsdSchemaChecker::checkElementDuplicates(), QPatternist::ColoringMessageHandler::ColoringMessageHandler(), QAxBase::connectNotify(), QDBusConnectionPrivate::connectSignal(), GraphPath::constraint(), QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints(), QPatternist::ConstructorFunctionsFactory::ConstructorFunctionsFactory(), convertWithPalette(), QPersistentModelIndexData::create(), QDialogButtonBoxPrivate::createButton(), QGraphicsAnchorLayoutPrivate::createCenterAnchors(), Graph< AnchorVertex, AnchorData >::createDirectedEdge(), QPatternist::XSLTTokenizer::createElementDescriptions(), QDeclarativeVisualDataModelPrivate::createMetaData(), QDBusMetaObject::createMetaObject(), QDeclarativeOpenMetaObjectType::createProperty(), createSlack(), QPatternist::XSLTTokenizer::createValidationAlternatives(), QDeclarativeXmlListModel::data(), NestedListModel::data(), QPatternist::GenericNamespaceResolver::defaultXQueryBindings(), QPatternist::GenericNamespaceResolver::defaultXSLTBindings(), QGestureManager::deliverEvents(), QNetworkManagerEngine::deviceAdded(), QPatternist::AccelTreeResourceLoader::deviceURIs(), QAxMetaObject::dispIDofName(), QPdfBaseEnginePrivate::drawTextItem(), QDeclarativePath::endpoint(), QDeclarativeVisualDataModelPrivate::ensureRoles(), QPatternist::FunctionAvailableFN::evaluateSingleton(), QNetworkAccessHttpBackend::fetchCacheMetaData(), flagDescriptions(), QDeclarativeListModel::flatten(), QConfFile::fromName(), QPatternist::FunctionFactoryCollection::functionSignatures(), QDeclarativeTypeLoader::get(), Maemo::GConfItemFast::getEntries(), QFreetypeFace::getFace(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QDeclarativeTypeLoader::getQmldir(), QDeclarativeTypeLoader::getScript(), QTextLine::glyphs(), QmlJSDebugger::AbstractViewInspector::handleMessage(), hasDuplicatedElementsInternal(), QDirModelPrivate::init(), QFileSystemModelPrivate::init(), QNetworkReplyImplPrivate::initCacheSaveDevice(), initDefaultPaths(), QGtkStylePrivate::initGtkWidgets(), QNetworkManagerEngine::initialize(), QProcessEnvironment::insert(), QSet< typename TokenLookupClass::NodeName >::insert(), QPMCache::insert(), QProcessEnvironmentPrivate::insert(), QPaintBufferResource::insert(), QPatternist::ColorOutput::insertMapping(), QDeclarativeXmlQueryEngine::instance(), internalParticleLookupMap(), QDeclarativePath::interpolate(), QAxServerBase::Invoke(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QPatternist::XsdSchemaHelper::isValidAttributeUsesExtension(), QPatternist::XsdSchemaHelper::isValidAttributeUsesRestriction(), QDeclarativeGridView::itemsMoved(), QDeclarativeListView::itemsMoved(), QDeclarativeDataLoader::load(), QTextDocumentWithImageResources::loadResource(), QReadWriteLock::lockForRead(), QMenuBarPrivate::macMenu(), QMenuPrivate::macMenu(), QPatternist::XsdTypeChecker::mergedFacetsForType(), MetaObjectGenerator::metaObject(), QPatternist::NamespaceSupport::NamespaceSupport(), QDeclarativeDataLoader::networkReplyFinished(), QDeclarativePixmapReader::networkRequestDone(), QPrintDialogPrivate::openCarbonPrintPanel(), QPatternist::Template::parametersAsHash(), QXmlStreamReaderPrivate::parse(), parseHttpOptionHeader(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QBBButtonEventNotifier::parsePPS(), QAxMetaObject::parsePrototype(), parseServerList(), QAuServerNAS::play(), QTextureGlyphCache::populate(), QJSDebuggerAgentPrivate::positionChange(), QScript::QObjectDelegate::put(), QAxScript::QAxScript(), QDBusConnectionPrivate::QDBusConnectionPrivate(), QDeclarativePackageAttached::QDeclarativePackageAttached(), QDeclarativeType::QDeclarativeType(), qmlAttachedPropertiesObjectById(), QDeclarativeTypeLoader::qmlDirParser(), QNetworkReplyPrivate::QNetworkReplyPrivate(), QScriptEnginePrivate::qobjectData(), qPRCreate(), qt_create_commandline(), qt_dispatchTabletProximityEvent(), qt_gl_choose_cmap(), qt_x11_set_fallback_font_family(), QSvgIconEngine::read(), MetaObjectGenerator::readEnumInfo(), MetaObjectGenerator::readEventInterface(), QInotifyFileSystemWatcherEngine::readFromInotify(), QNetworkReplyImplPrivate::redirectionRequested(), QDeclarativeMetaType::registerCustomStringConverter(), QDeclarativeVMEMetaObject::registerInterceptor(), registerInterface(), QEventDispatcherWin32::registerSocketNotifier(), QDeclarativeBindingCompilerPrivate::registerString(), QEventDispatcherMac::registerTimer(), registerType(), QGraphicsAnchorLayoutPrivate::removeInternalVertex(), QMultiHash< const QGLContext *, GLProgram >::replace(), QPatternist::XsdSchemaResolver::resolveAttributeInheritance(), QPatternist::XsdSchemaResolver::resolveSimpleContentComplexTypes(), QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(), QPatternist::AccelTreeResourceLoader::retrieveUnparsedText(), QHeaderViewPrivate::saveCascadingSectionSize(), QScriptDebuggerPrivate::scheduleCommand(), QJSDebuggerAgent::scriptLoad(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), QSqlRelationalTableModel::selectStatement(), QNetworkRequest::setAttribute(), QNetworkAccessBackend::setAttribute(), QDeclarativeListModelParser::setCustomData(), QScriptEnginePrivate::setDefaultPrototype(), QApplication::setFont(), QmlJSDebugger::LiveSelectionIndicator::setItems(), ModelNode::setObjectValue(), QAuthenticator::setOption(), QStyleSheetStyle::setPalette(), QApplicationPrivate::setPalette_helper(), QSettings::setPath(), QPatternist::NamespaceSupport::setPrefix(), QPatternist::NamespaceSupport::setPrefixes(), FlatListModel::setProperty(), ModelNode::setProperty(), QNetworkSessionPrivateImpl::setSessionProperty(), QPatternist::NamespaceSupport::setTargetNamespace(), QPatternist::XsdSchemaChecker::setupAllowedAtomicFacets(), QPatternist::XsdSchemaContext::setupBuiltinTypesFacetList(), QRegExpEngine::setupCategoriesRangeMap(), QDesktopServices::setUrlHandler(), QSimplex::simplifyConstraints(), QGraphicsAnchorLayoutPrivate::solveMinMax(), QGraphicsAnchorLayoutPrivate::solvePreferred(), QWidgetPrivate::stackUnder_sys(), QStyleSheetStyle::styleRules(), QDeclarativeBindingCompilerPrivate::subscriptionIndex(), QProcessEnvironment::systemEnvironment(), MetaObjectGenerator::tryCache(), QReadWriteLock::tryLockForRead(), QPatternist::ElementConstructor::typeCheck(), QPatternist::NamePool::unlockedAllocateLocalName(), QPatternist::NamePool::unlockedAllocateNamespace(), QPatternist::NamePool::unlockedAllocatePrefix(), QGestureManager::unregisterGestureRecognizer(), QBBEngine::updateConfiguration(), QPatternist::XsdValidatingInstanceReader::validateElementComplexType(), QSvgIconEngine::write(), and QPatternist::XsdSchemaTypesFactory::XsdSchemaTypesFactory().

755 {
756  detach();
757 
758  uint h;
759  Node **node = findNode(akey, &h);
760  if (*node == e) {
761  if (d->willGrow())
762  node = findNode(akey, &h);
763  return iterator(createNode(h, akey, avalue, node));
764  }
765 
767  (*node)->value = avalue;
768  return iterator(*node);
769 }
QHashData * d
Definition: qhash.h:264
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
unsigned int uint
Definition: qglobal.h:996
Node * createNode(uint h, const Key &key, const T &value, Node **nextNode)
Definition: qhash.h:538
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303
QHashNode< Key, T > * e
Definition: qhash.h:265
bool willGrow()
Definition: qhash.h:160
friend class iterator
Definition: qhash.h:393

◆ insertMulti()

template<class Key, class T>
Q_INLINE_TEMPLATE QHash< Key, T >::iterator QHash< Key, T >::insertMulti ( const Key &  key,
const T &  value 
)

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 insert(), which overwrites the value of an existing item.)

See also
insert(), values()

Definition at line 772 of file qhash.h.

Referenced by QDeclarativeVisualDataModel::_q_itemsRemoved(), QDBusConnectionPrivate::connectSignal(), QDirModelPrivate::init(), QFileSystemModelPrivate::init(), QMultiHash< const QGLContext *, GLProgram >::insert(), QDomDocumentTypePrivate::insertAfter(), QDomDocumentTypePrivate::insertBefore(), QTextDocumentLayoutPrivate::layoutTable(), operator>>(), qDBusRealAddWatch(), QDomDocumentTypePrivate::QDomDocumentTypePrivate(), registerType(), QDomDocumentTypePrivate::replaceChild(), QJSDebuggerAgent::setBreakpoints(), and QTextControl::setExtraSelections().

774 {
775  detach();
776  d->willGrow();
777 
778  uint h;
779  Node **nextNode = findNode(akey, &h);
780  return iterator(createNode(h, akey, avalue, nextNode));
781 }
QHashData * d
Definition: qhash.h:264
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
unsigned int uint
Definition: qglobal.h:996
Node * createNode(uint h, const Key &key, const T &value, Node **nextNode)
Definition: qhash.h:538
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303
bool willGrow()
Definition: qhash.h:160
friend class iterator
Definition: qhash.h:393

◆ isDetached()

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

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

Warning
This function is not part of the public interface.
See also
detach()

Definition at line 304 of file qhash.h.

Referenced by QSet< typename TokenLookupClass::NodeName >::isDetached().

304 { return d->ref == 1; }
QBasicAtomicInt ref
Definition: qhash.h:121
QHashData * d
Definition: qhash.h:264

◆ isEmpty()

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

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

See also
size()

Definition at line 297 of file qhash.h.

Referenced by _q_dupEnvironment(), QStateMachinePrivate::applyProperties(), QPatternist::XQueryTokenizer::charForReference(), QPatternist::XsdSchemaChecker::checkConstrainingFacets(), QPatternist::XsdSchemaChecker::checkElementDuplicates(), QPatternist::XsdSchemaChecker::checkSimpleTypeConstraints(), QObjectPrivate::clearGuards(), QDeclarativeVisualDataModelPrivate::ensureRoles(), QGtkStyleFilter::eventFilter(), QCoreTextFontDatabase::fallbacksForFamily(), QDeclarativeJS::Ecma::RegExp::flagFromChar(), QRegExpEngine::getEscape(), getPath(), QTextDocumentLayoutPrivate::hitTest(), initDefaultPaths(), initFontSubst(), QApplicationPrivate::initializeWidgetPaletteHash(), QDeclarativeTimeLine::isActive(), QSet< typename TokenLookupClass::NodeName >::isEmpty(), QProcessEnvironment::isEmpty(), QCache< QPixmapCache::Key, QPixmapCacheEntry >::isEmpty(), QPatternist::XsdSchemaHelper::isSimpleDerivationOk(), QTextureGlyphCache::populate(), QPatternist::NamespaceSupport::processName(), qt_create_commandline(), qt_gl_choose_cmap(), QFreetypeFace::release(), QDeclarativeTimeLine::remove(), Graph< AnchorVertex, AnchorData >::removeDirectedEdge(), QMetaObject::removeGuard(), QKqueueFileSystemWatcherEngine::removePaths(), QWindowsFileSystemWatcherEngine::removePaths(), QWindowsFileSystemWatcherEngineThread::run(), QDomElementPrivate::save(), QSettings::setPath(), QTextDocumentWithImageResources::setText(), QSimplex::simplifyConstraints(), QGraphicsScenePrivate::touchEventHandler(), QApplicationPrivate::translateRawTouchEvent(), QDeclarativeTimeLine::updateCurrentTime(), updateWidgets(), NestedListModel::valueForNode(), and QTextDocumentWithImageResources::~QTextDocumentWithImageResources().

297 { return d->size == 0; }
int size
Definition: qhash.h:122
QHashData * d
Definition: qhash.h:264

◆ isSharedWith()

template<class Key, class T>
bool QHash< Key, T >::isSharedWith ( const QHash< Key, T > &  other) const
inline
Warning
This function is not part of the public interface.

Definition at line 306 of file qhash.h.

306 { return d == other.d; }
QHashData * d
Definition: qhash.h:264

◆ key() [1/2]

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

Returns the first key mapped to value.

If the hash contains no item with the value, the function returns a default-constructed key.

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

See also
value(), keys()

Definition at line 674 of file qhash.h.

Referenced by QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QPMCache::allPixmaps(), QStateMachinePrivate::applyProperties(), QDeclarativeVisualDataModelPrivate::createMetaData(), QParallelAnimationGroupPrivate::disconnectUncontrolledAnimations(), Graph< Vertex, EdgeData >::const_iterator::from(), QTextFormatCollection::hasFormatCached(), QTextFormatCollection::indexForFormat(), QMacPrintEnginePrivate::initialize(), QHeaderView::initializeSections(), QProcessEnvironmentPrivate::insert(), QSimplexConstraint::isSatisfied(), Graph< Vertex, EdgeData >::const_iterator::operator*(), operator<<(), QDialogButtonBoxPrivate::retranslateStrings(), QScriptDebuggerCodeWidgetPrivate::scriptId(), QSimplex::setConstraints(), QSimplex::simplifyConstraints(), QSimplex::solver(), Graph< Vertex, EdgeData >::const_iterator::to(), QSimplexConstraint::toString(), unregWinClasses(), QDeclarativeGridViewPrivate::updateUnrequestedIndexes(), QDeclarativeListViewPrivate::updateUnrequestedIndexes(), QDeclarativeGridViewPrivate::updateUnrequestedPositions(), and QDeclarativeListViewPrivate::updateUnrequestedPositions().

675 {
676  return key(avalue, Key());
677 }
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ key() [2/2]

template<class Key, class T>
Q_OUTOFLINE_TEMPLATE const Key QHash< Key, T >::key ( const T &  value,
const Key &  defaultKey 
) const

Returns the first key mapped to value, or defaultKey if the hash contains no item mapped to value.

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.

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

Definition at line 680 of file qhash.h.

681 {
682  const_iterator i = begin();
683  while (i != end()) {
684  if (i.value() == avalue)
685  return i.key();
686  ++i;
687  }
688 
689  return defaultValue;
690 }
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
friend class const_iterator
Definition: qhash.h:461

◆ keys() [1/2]

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

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

Keys that occur multiple times in the hash (because items were inserted with insertMulti(), or unite() was used) also occur multiple times in the list.

To obtain a list of unique keys, where each key from the map only occurs once, use uniqueKeys().

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

See also
uniqueKeys(), values(), key()

Definition at line 648 of file qhash.h.

Referenced by Graph< AnchorVertex, AnchorData >::adjacentVertices(), QDeclarativeDebugConnectionPrivate::advertisePlugins(), QDeclarativeDebugServerPrivate::advertisePlugins(), QPatternist::XsdInstanceReader::attributeNames(), QPatternist::XsdSchemaChecker::checkConstrainingFacets(), NestedListModel::checkRoles(), QGLGlyphCache::cleanupContext(), QGestureManager::cleanupGesturesForRemovedRecognizer(), QDeclarativeDebugConnectionPrivate::connected(), QGestureManager::getGestureTargets(), QGraphicsAnchorLayoutPrivate::getGraphParts(), getVariables(), QCache< QPixmapCache::Key, QPixmapCacheEntry >::keys(), printHelp(), QDeclarativePropertyCache::propertyNames(), qDBusRealAddTimeout(), QDeclarativeMetaType::qmlTypeNames(), QSvgIconEngine::read(), QStyleSheetStyle::repolish(), FlatListModel::roles(), QNetworkManagerEngine::sessionStateForId(), QStyleSheetStyle::setProperties(), QGestureManager::unregisterGestureRecognizer(), QSvgIconEngine::write(), and QGestureManager::~QGestureManager().

649 {
650  QList<Key> res;
651  res.reserve(size());
652  const_iterator i = begin();
653  while (i != end()) {
654  res.append(i.key());
655  ++i;
656  }
657  return res;
658 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
friend class const_iterator
Definition: qhash.h:461
void reserve(int size)
Reserve space for alloc elements.
Definition: qlist.h:496
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ keys() [2/2]

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

Returns a list containing all the keys associated with value value, in an arbitrary order.

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

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

Definition at line 661 of file qhash.h.

662 {
663  QList<Key> res;
664  const_iterator i = begin();
665  while (i != end()) {
666  if (i.value() == avalue)
667  res.append(i.key());
668  ++i;
669  }
670  return res;
671 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
friend class const_iterator
Definition: qhash.h:461
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ operator!=()

template<class Key, class T>
bool QHash< Key, T >::operator!= ( const QHash< Key, T > &  other) const
inline

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

293 { return !(*this == other); }

◆ operator=()

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

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

Definition at line 591 of file qhash.h.

592 {
593  if (d != other.d) {
594  QHashData *o = other.d;
595  o->ref.ref();
596  if (!d->ref.deref())
597  freeData(d);
598  d = o;
599  if (!d->sharable)
600  detach_helper();
601  }
602  return *this;
603 }
QBasicAtomicInt ref
Definition: qhash.h:121
void detach_helper()
Definition: qhash.h:580
QHashData * d
Definition: qhash.h:264
uint sharable
Definition: qhash.h:127
void freeData(QHashData *d)
Definition: qhash.h:568

◆ operator==()

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

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

899 {
900  if (size() != other.size())
901  return false;
902  if (d == other.d)
903  return true;
904 
905  const_iterator it = begin();
906 
907  while (it != end()) {
908  const Key &akey = it.key();
909 
910  const_iterator it2 = other.find(akey);
911  do {
912  if (it2 == other.end() || !(it2.key() == akey))
913  return false;
914  if (!QTypeInfo<T>::isDummy && !(it.value() == it2.value()))
915  return false;
916  ++it;
917  ++it2;
918  } while (it != end() && it.key() == akey);
919  }
920  return true;
921 }
#define it(className, varName)
QHashData * d
Definition: qhash.h:264
const Key & key() const
Returns the current item&#39;s key as a const reference.
Definition: qhash.h:347
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
friend class const_iterator
Definition: qhash.h:461

◆ operator[]() [1/2]

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

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

If the hash contains no item with the key, the function inserts a 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 738 of file qhash.h.

739 {
740  detach();
741 
742  uint h;
743  Node **node = findNode(akey, &h);
744  if (*node == e) {
745  if (d->willGrow())
746  node = findNode(akey, &h);
747  return createNode(h, akey, T(), node)->value;
748  }
749  return (*node)->value;
750 }
QHashData * d
Definition: qhash.h:264
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
unsigned int uint
Definition: qglobal.h:996
Node * createNode(uint h, const Key &key, const T &value, Node **nextNode)
Definition: qhash.h:538
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303
QHashNode< Key, T > * e
Definition: qhash.h:265
bool willGrow()
Definition: qhash.h:160
T value
Definition: qhash.h:221

◆ operator[]() [2/2]

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

Same as value().

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

733 {
734  return value(akey);
735 }
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606

◆ remove()

template<class Key, class T >
Q_OUTOFLINE_TEMPLATE int QHash< Key, T >::remove ( const Key &  key)

Removes all the items that have the key from the hash.

Returns the number of items removed which is usually 1 but will be 0 if the key isn't in the hash, or greater than 1 if insertMulti() has been used with the key.

See also
clear(), take(), QMultiHash::remove()

Definition at line 784 of file qhash.h.

Referenced by QPatternist::GenericNamespaceResolver::addBinding(), QPatternist::DelegatingNamespaceResolver::addBinding(), QStateMachinePrivate::applyProperties(), QGestureManager::cleanupCachedGestures(), QGestureManager::cleanupGesturesForRemovedRecognizer(), QCoreGraphicsPaintEngine::clearColorSpace(), QPrintDialogPrivate::closeCarbonPrintPanel(), QGestureManager::filterEventThroughContexts(), QPMCache::insert(), QFSFileEnginePrivate::longFileName(), QDeclarativeEngineDebugPrivate::message(), QPMCache::object(), QMultiHash< const QGLContext *, GLProgram >::operator+(), QStyleSheetStyle::polish(), qt_dispatchTabletProximityEvent(), qt_x11_set_fallback_font_family(), QInotifyFileSystemWatcherEngine::readFromInotify(), QDeclarativeEngineDebugPrivate::remove(), QProcessEnvironment::remove(), QSet< typename TokenLookupClass::NodeName >::remove(), QPMCache::remove(), QDomDocumentTypePrivate::removeChild(), QBBEngine::removeConfiguration(), Graph< AnchorVertex, AnchorData >::removeDirectedEdge(), QNetworkAccessCache::removeEntry(), QGraphicsAnchorLayoutPrivate::removeInternalVertex(), QGraphicsScenePrivate::removeItemHelper(), QWindowsFileSystemWatcherEngine::removePaths(), QWSPropertyManager::removeProperties(), QWSPropertyManager::removeProperty(), QFont::removeSubstitution(), QDirectFbInput::removeWindow(), QDomDocumentTypePrivate::replaceChild(), QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(), QKqueueFileSystemWatcherEngine::run(), QWindowsFileSystemWatcherEngineThread::run(), QJSDebuggerAgent::scriptUnload(), QNetworkRequest::setAttribute(), QNetworkAccessBackend::setAttribute(), QAuServerNAS::setDone(), QNetworkSessionPrivateImpl::setSessionProperty(), QDesktopServices::setUrlHandler(), QAuServerNAS::soundDestroyed(), QNetworkAccessCache::timerEvent(), QCache< QPixmapCache::Key, QPixmapCacheEntry >::unlink(), QFSFileEnginePrivate::unmap(), QStyleSheetStyle::unpolish(), QStateMachinePrivate::unregisterEventTransition(), QGestureManager::unregisterGestureRecognizer(), QStateMachinePrivate::unregisterSignalTransition(), QEventDispatcherWin32::unregisterSocketNotifier(), QStyleSheetStyle::unsetPalette(), updateWidgets(), QConfFileSettingsPrivate::~QConfFileSettingsPrivate(), QDeclarativePackageAttached::~QDeclarativePackageAttached(), QDeclarativePixmapReader::~QDeclarativePixmapReader(), QDeclarativeXmlQueryEngine::~QDeclarativeXmlQueryEngine(), and QMenuPrivate::QMacMenuPrivate::~QMacMenuPrivate().

785 {
786  if (isEmpty()) // prevents detaching shared null
787  return 0;
788  detach();
789 
790  int oldSize = d->size;
791  Node **node = findNode(akey);
792  if (*node != e) {
793  bool deleteNext = true;
794  do {
795  Node *next = (*node)->next;
796  deleteNext = (next != e && next->key == (*node)->key);
797  deleteNode(*node);
798  *node = next;
799  --d->size;
800  } while (deleteNext);
801  d->hasShrunk();
802  }
803  return oldSize - d->size;
804 }
int size
Definition: qhash.h:122
QHashData * d
Definition: qhash.h:264
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303
QHashNode< Key, T > * e
Definition: qhash.h:265
void deleteNode(Node *node)
Definition: qhash.h:509
void hasShrunk()
Definition: qhash.h:170

◆ reserve()

template<class Key , class T >
Q_INLINE_TEMPLATE void QHash< Key, T >::reserve ( int  size)

Ensures that the QHash's internal hash table consists of at least size buckets.

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

hash.reserve(20000);
for (int i = 0; i < 20000; ++i)
hash.insert(keys[i], values[i]);

Ideally, size should be slightly more than the maximum number of items expected in the hash. size doesn't have to be prime, because QHash will use a prime number internally anyway. 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 shrinks or grows to provide good performance without wasting too much memory.

See also
squeeze(), capacity()

Definition at line 846 of file qhash.h.

Referenced by QPatternist::AccelTree::AccelTree(), QPatternist::BasicTypesFactory::BasicTypesFactory(), QPatternist::XQueryTokenizer::charForReference(), QPatternist::XSLTTokenizer::createElementDescriptions(), QPatternist::GenericStaticContext::GenericStaticContext(), QPatternist::NamePool::NamePool(), QXmlSerializerPrivate::QXmlSerializerPrivate(), QSet< typename TokenLookupClass::NodeName >::reserve(), and QPatternist::XsdSchemaTypesFactory::XsdSchemaTypesFactory().

847 {
848  detach();
849  d->rehash(-qMax(asize, 1));
850 }
QHashData * d
Definition: qhash.h:264
void rehash(int hint)
Definition: qhash.cpp:349
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303

◆ setSharable()

template<class Key, class T>
void QHash< Key, T >::setSharable ( bool  sharable)
inline
Warning
This function is not part of the public interface.

Definition at line 305 of file qhash.h.

Referenced by QSet< typename TokenLookupClass::NodeName >::setSharable().

305 { if (!sharable) detach(); d->sharable = sharable; }
QHashData * d
Definition: qhash.h:264
uint sharable
Definition: qhash.h:127
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303

◆ size()

template<class Key, class T>
int QHash< Key, T >::size ( ) const
inline

◆ squeeze()

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

Referenced by QSet< typename TokenLookupClass::NodeName >::squeeze().

301 { reserve(1); }
void reserve(int size)
Ensures that the QHash&#39;s internal hash table consists of at least size buckets.
Definition: qhash.h:846

◆ swap()

template<class Key, class T>
void QHash< Key, T >::swap ( QHash< Key, T > &  other)
inline

Swaps hash other with this hash.

Since
4.8

This operation is very fast and never fails.

Definition at line 290 of file qhash.h.

Referenced by QSet< typename TokenLookupClass::NodeName >::swap(), and QMultiHash< const QGLContext *, GLProgram >::swap().

290 { qSwap(d, other.d); }
QHashData * d
Definition: qhash.h:264
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181

◆ take()

template<class Key, class T >
Q_OUTOFLINE_TEMPLATE T QHash< Key, T >::take ( const Key &  key)

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

Referenced by QStateMachinePrivate::_q_animationFinished(), QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(), QSqlDatabasePrivate::addDatabase(), QStateMachinePrivate::applyProperties(), QGLGlyphCache::cleanupContext(), QNetworkManagerEngine::deviceRemoved(), QGLGlyphCache::fontEngineDestroyed(), QScriptDebuggerPrivate::handleResponse(), QDeclarativeGridView::itemsMoved(), QDeclarativeListView::itemsMoved(), QDeclarativeDataLoader::networkReplyFinished(), QDeclarativePixmapReader::networkRequestDone(), QAxScriptManager::objectDestroyed(), QFreetypeFace::release(), QDBusConnectionManager::removeConnection(), QSqlDatabasePrivate::removeDatabase(), QInotifyFileSystemWatcherEngine::removePaths(), QKqueueFileSystemWatcherEngine::removePaths(), QDeclarativeWatcher::removeWatch(), QSimplex::simplifyConstraints(), and QEventDispatcherMac::unregisterTimer().

808 {
809  if (isEmpty()) // prevents detaching shared null
810  return T();
811  detach();
812 
813  Node **node = findNode(akey);
814  if (*node != e) {
815  T t = (*node)->value;
816  Node *next = (*node)->next;
817  deleteNode(*node);
818  *node = next;
819  --d->size;
820  d->hasShrunk();
821  return t;
822  }
823  return T();
824 }
int size
Definition: qhash.h:122
QHashData * d
Definition: qhash.h:264
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
void detach()
Detaches this hash from any other hashes with which it may share data.
Definition: qhash.h:303
QHashNode< Key, T > * e
Definition: qhash.h:265
void deleteNode(Node *node)
Definition: qhash.h:509
void hasShrunk()
Definition: qhash.h:170

◆ uniqueKeys()

template<class Key , class T >
Q_OUTOFLINE_TEMPLATE QList< Key > QHash< Key, T >::uniqueKeys ( ) const

Returns a list containing all the keys in the map.

Since
4.2

Keys that occur multiple times in the map (because items were inserted with insertMulti(), or unite() was used) occur only once in the returned list.

See also
keys(), values()

Definition at line 628 of file qhash.h.

629 {
630  QList<Key> res;
631  res.reserve(size()); // May be too much, but assume short lifetime
632  const_iterator i = begin();
633  if (i != end()) {
634  for (;;) {
635  const Key &aKey = i.key();
636  res.append(aKey);
637  do {
638  if (++i == end())
639  goto break_out_of_outer_loop;
640  } while (aKey == i.key());
641  }
642  }
643 break_out_of_outer_loop:
644  return res;
645 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
friend class const_iterator
Definition: qhash.h:461
void reserve(int size)
Reserve space for alloc elements.
Definition: qlist.h:496
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ unite()

template<class Key, class T>
Q_INLINE_TEMPLATE QHash< Key, T > & QHash< Key, T >::unite ( const QHash< Key, T > &  other)

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

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

See also
insertMulti()

Definition at line 556 of file qhash.h.

Referenced by QPatternist::XsdSchemaChecker::addComponentLocationHash(), QPatternist::XsdSchemaResolver::addComponentLocationHash(), and QPatternist::XsdParticleChecker::subsumes().

557 {
558  QHash<Key, T> copy(other);
559  const_iterator it = copy.constEnd();
560  while (it != copy.constBegin()) {
561  --it;
562  insertMulti(it.key(), it.value());
563  }
564  return *this;
565 }
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:772
friend class const_iterator
Definition: qhash.h:461

◆ value() [1/2]

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

Returns the value associated with the key.

If the hash contains no item with the key, the function returns a default-constructed value. If there are multiple items for the key in the hash, the value of the most recently inserted one is returned.

See also
key(), values(), contains(), operator[]()

Definition at line 606 of file qhash.h.

Referenced by QStateMachinePrivate::_q_animationFinished(), QNetworkReplyImplPrivate::_q_copyReadyRead(), QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsAboutToBeRemoved(), QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsDataChanged(), QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsInserted(), QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QEventDispatcherMacPrivate::activateTimer(), QNetworkManagerEngine::activeConnectionPropertiesChanged(), QSvgIconEngine::actualSize(), QMenuPrivate::QMacMenuPrivate::addAction(), MetaObjectGenerator::addChangedSignal(), QPdfEnginePrivate::addConstantAlphaObject(), QPdfEnginePrivate::addImage(), QGraphicsAnchorLayoutPrivate::addInternalVertex(), QWindowsFileSystemWatcherEngine::addPaths(), FlatListModel::addValue(), Graph< AnchorVertex, AnchorData >::adjacentVertices(), QPMCache::allPixmaps(), QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions(), QStateMachinePrivate::applyProperties(), QScriptEngineAgentPrivate::atStatement(), QDeclarativeMetaType::attachedPropertiesFuncId(), QNetworkRequest::attribute(), QPatternist::XsdInstanceReader::attribute(), QStyleSheetStyleSelector::attribute(), QDeclarativePath::attributeAt(), QPatternist::XsdInstanceReader::attributeItem(), QGraphicsAnchorLayoutPrivate::calculateGraphs(), QGestureManager::cancelGesturesForChildren(), QPatternist::XQueryTokenizer::charForReference(), QPatternist::XsdSchemaChecker::checkAttributeUseConstraints(), QPatternist::XsdSchemaChecker::checkConstrainingFacets(), QPatternist::XsdTypeChecker::checkConstrainingFacetsBinary(), QPatternist::XsdTypeChecker::checkConstrainingFacetsBoolean(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDateTime(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDecimal(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDouble(), QPatternist::XsdTypeChecker::checkConstrainingFacetsDuration(), QPatternist::XsdTypeChecker::checkConstrainingFacetsList(), QPatternist::XsdTypeChecker::checkConstrainingFacetsNotation(), QPatternist::XsdTypeChecker::checkConstrainingFacetsQName(), QPatternist::XsdTypeChecker::checkConstrainingFacetsSignedInteger(), QPatternist::XsdTypeChecker::checkConstrainingFacetsString(), QPatternist::XsdTypeChecker::checkConstrainingFacetsUnion(), QPatternist::XsdTypeChecker::checkConstrainingFacetsUnsignedInteger(), QPatternist::XsdSchemaChecker::checkElementDuplicates(), QGestureManager::cleanupGesturesForRemovedRecognizer(), QGtkStylePrivate::cleanupGtkWidgets(), QCoreGraphicsPaintEngine::cleanUpMacColorSpaces(), QPatternist::ColorOutput::colorify(), QPatternist::ColoringMessageHandler::colorifyDescription(), EGLNullWSScreen::connect(), QDBusConnectionManager::connection(), QScriptEnginePrivate::convertValue(), convertWithPalette(), QScriptEnginePrivate::create(), Graph< AnchorVertex, AnchorData >::createDirectedEdge(), QDBusMetaObject::createMetaObject(), QPatternist::XsdSchemaTypesFactory::createSchemaType(), QPatternist::BasicTypesFactory::createSchemaType(), QDeclarativeMetaType::customStringConverter(), QDeclarativeTypeNameCache::data(), QSqlDatabasePrivate::database(), QScriptEnginePrivate::defaultPrototype(), QScriptDebuggerAgent::deleteBreakpoint(), QGestureManager::deliverEvents(), derivedTermValid(), QScriptEngineAgentPrivate::didReachBreakpoint(), QAuthenticatorPrivate::digestMd5Response(), QAxMetaObject::dispIDofName(), QMacStyle::drawControl(), QPdfBaseEnginePrivate::drawTextItem(), Graph< AnchorVertex, AnchorData >::edgeData(), QPatternist::AccelTree::elementById(), QDeclarativePath::endpoint(), QPatternist::XsdStateMachine< XsdSchemaToken::NodeName >::epsilonClosure(), familyNameFromPostScriptName(), QNetworkAccessHttpBackend::fetchCacheMetaData(), QWSPropertyManager::Data::find(), QWidget::find(), QDBusConnectionPrivate::findMetaObject(), QAxScript::findObject(), QGraphicsAnchorLayoutPrivate::findPaths(), QNetworkReplyImplPrivate::finished(), QPMCache::flushDetachedPixmaps(), QApplication::font(), QConfFile::fromName(), QGraphicsScenePrivate::gestureEventHandler(), QDeclarativeTypeLoader::get(), QRegExpEngine::getEscape(), QFreetypeFace::getFace(), QGestureManager::getGestureTargets(), QBBEngine::getInterfaceFromId(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), getPath(), QWSPropertyManager::getProperty(), QDeclarativeTypeLoader::getQmldir(), QDeclarativeTypeLoader::getScript(), QSharedNetworkSessionManager::getSession(), QGestureManager::getState(), QComboMenuDelegate::getStyleOption(), QGtkStylePrivate::gtkWidget(), QDirectFbInput::handleEnterLeaveEvents(), QStateMachinePrivate::handleFilteredEvent(), QDirectFbInput::handleKeyEvents(), QDirectFbInput::handleMouseEvents(), QDBusConnectionPrivate::handleSignal(), QDirectFbInput::handleWheelEvent(), hasDuplicatedElementsInternal(), QTextFormatCollection::hasFormatCached(), QSqlResult::hasOutValues(), QDeclarativePackage::hasPart(), QWSPropertyManager::hasProperty(), QStyleSheetStyle::hasStyleRule(), QNetworkRequest::header(), QmlJSDebugger::AbstractViewInspector::idStringForObject(), QTextFormatCollection::indexForFormat(), QMacPrintEnginePrivate::initialize(), QPMCache::insert(), QProcessEnvironmentPrivate::insert(), QDeclarativeXmlQueryEngine::instance(), QDeclarativeMetaType::interfaceIId(), QDeclarativePath::interpolate(), QSimplexConstraint::invert(), QAxServerBase::Invoke(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QSimplexConstraint::isSatisfied(), QPatternist::XsdParticleChecker::isUPAConform(), QPatternist::XsdSchemaHelper::isValidAttributeUsesRestriction(), QDeclarativeMetaType::listType(), QPatternist::GenericDynamicContext::locationFor(), QPatternist::GenericStaticContext::locationFor(), QReadWriteLock::lockForRead(), QPatternist::GenericNamespaceResolver::lookupNamespaceURI(), QPatternist::DelegatingNamespaceResolver::lookupNamespaceURI(), QScript::QObjectDelegate::markChildren(), QMenuPrivate::QMacMenuPrivate::merged(), QDeclarativeEngineDebugPrivate::message(), QDeclarativeVMEMetaObject::metaCall(), QNetworkReplyImplPrivate::metaDataChanged(), QPatternist::XsdStateMachine< XsdSchemaToken::NodeName >::move(), QSvgTinyDocument::namedNode(), QSvgTinyDocument::namedStyle(), QPatternist::AccelTree::namespaceBindings(), QDeclarativeDataLoader::networkReplyProgress(), QPatternist::XsdTypeChecker::normalizedValue(), QAxMetaObject::numParameter(), QPMCache::object(), QPatternist::AccelTreeResourceLoader::openUnparsedText(), operator<<(), QHash< QExplicitlySharedDataPointer, QHash >::operator[](), QAuthenticator::option(), QAxMetaObject::paramType(), QAuthenticatorPrivate::parseDigestAuthenticationChallenge(), QPatternist::PatternPlatform::parseFlags(), QAuthenticatorPrivate::parseHttpResponse(), parseServerList(), QDeclarativePackage::part(), QSvgIconEngine::pixmap(), QJSDebuggerAgentPrivate::positionChange(), QPrintDialogPrivate::printDialogSheetDoneCallback(), QPatternist::AccelTree::printStats(), QPatternist::XsdStateMachine< XsdSchemaToken::NodeName >::proceed(), QPatternist::NamespaceSupport::processName(), QDeclarativePath::processPath(), FlatListScriptClass::property(), QDeclarativePropertyCache::property(), QScript::QObjectDelegate::put(), qDBusRemoveWatch(), qmlAttachedPropertiesObjectById(), QDeclarativeMetaType::qmlType(), qPRFindWidget(), qt_aqua_get_known_size(), qt_fallback_font_family(), qt_internal_proc(), qt_mac_handleTabletEvent(), qt_mac_set_modal_state(), qt_mac_socket_callback(), QAxServerBase::qt_metacall(), QtWndProc(), QSvgIconEngine::read(), MetaObjectGenerator::readEnumInfo(), MetaObjectGenerator::readEventInfo(), MetaObjectGenerator::readEventInterface(), QInotifyFileSystemWatcherEngine::readFromInotify(), QGestureManager::recycle(), QPMCache::remove(), QGraphicsAnchorLayoutPrivate::removeAnchor(), Graph< AnchorVertex, AnchorData >::removeDirectedEdge(), QGraphicsAnchorLayoutPrivate::removeInternalVertex(), QWindowsFileSystemWatcherEngine::removePaths(), QPatternist::XsdSchemaResolver::resolveEnumerationFacetValues(), QPatternist::XsdSchemaResolver::resolveSimpleContentComplexTypes(), QDialogButtonBoxPrivate::retranslateStrings(), QPatternist::ConstructorFunctionsFactory::retrieveFunctionSignature(), QPatternist::FunctionFactoryCollection::retrieveFunctionSignature(), QKqueueFileSystemWatcherEngine::run(), QWindowsFileSystemWatcherEngineThread::run(), QAxScriptManager::script(), QMenuPrivate::scrollMenu(), QSqlRelationalTableModel::selectStatement(), QNetworkAccessCacheBackend::sendCacheContents(), QNetworkAccessHttpBackend::sendCacheContents(), QPatternist::AccelTree::sendNamespaces(), QEventDispatcherWin32Private::sendTimerEvent(), QNetworkSessionPrivateImpl::sessionProperty(), QNetworkManagerEngine::sessionStateForId(), QSimplex::setConstraints(), QMenuPrivate::setCurrentAction(), QScriptEnginePrivate::setDefaultPrototype(), QTextControl::setExtraSelections(), ModelNode::setObjectValue(), QWSPropertyManager::setProperty(), FlatListScriptClass::setProperty(), QSimplex::simplifyConstraints(), QSimplex::solver(), QPatternist::XsdSchemaChecker::sourceLocation(), QPatternist::AccelTree::sourceLocation(), QPatternist::XsdSchemaResolver::sourceLocation(), QPatternist::AccelTree::stringValue(), QRenderRule::styleHint(), QStyleSheetStyle::styleRules(), QMacStyle::subControlRect(), QStyleSheetStyle::subControlRect(), QFont::substitutes(), QPatternist::XsdParticleChecker::subsumes(), QDBusConnectionPrivate::timerEvent(), QDockWidgetLayout::titleHeight(), QSimplexConstraint::toString(), MetaObjectGenerator::tryCache(), QReadWriteLock::tryLockForRead(), QPatternist::XsdSchema::type(), QReadWriteLock::unlock(), QPatternist::NamePool::unlockedAllocateLocalName(), QPatternist::NamePool::unlockedAllocateNamespace(), QPatternist::NamePool::unlockedAllocatePrefix(), QFSFileEnginePrivate::unmap(), QStateMachinePrivate::unregisterEventTransition(), QGestureManager::unregisterGestureRecognizer(), QEventDispatcherWin32::unregisterSocketNotifier(), QStyleSheetStyle::unsetPalette(), QMenuPrivate::updateActionRects(), QBBButtonEventNotifier::updateButtonStates(), QPatternist::NamespaceSupport::uri(), QPatternist::XsdValidatingInstanceReader::validateElementComplexType(), QDeclarativeIntegerCache::value(), QSvgIconEngine::write(), and QGestureManager::~QGestureManager().

607 {
608  Node *node;
609  if (d->size == 0 || (node = *findNode(akey)) == e) {
610  return T();
611  } else {
612  return node->value;
613  }
614 }
int size
Definition: qhash.h:122
QHashData * d
Definition: qhash.h:264
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
QHashNode< Key, T > * e
Definition: qhash.h:265

◆ value() [2/2]

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

If the hash contains no item with the given key, the function returns defaultValue.

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

618 {
619  Node *node;
620  if (d->size == 0 || (node = *findNode(akey)) == e) {
621  return adefaultValue;
622  } else {
623  return node->value;
624  }
625 }
int size
Definition: qhash.h:122
QHashData * d
Definition: qhash.h:264
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
QHashNode< Key, T > * e
Definition: qhash.h:265

◆ values() [1/2]

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

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

If a key is associated 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().

See also
keys(), value()

Definition at line 693 of file qhash.h.

Referenced by QPatternist::XsdSchema::anonymousTypes(), QStateMachinePrivate::applyProperties(), ModelNode::clear(), QPatternist::XsdSchema::complexTypes(), QGraphicsAnchorLayoutPrivate::constraintsFromPaths(), QIcdEngine::doRequestUpdate(), QTextDocumentLayoutPrivate::drawTableCell(), QTextLine::glyphs(), QTextDocumentLayoutPrivate::hitTest(), QTextDocumentLayoutPrivate::layoutCell(), QDeclarativeMetaType::qmlType(), QDeclarativeMetaType::qmlTypes(), shiftConstraints(), QPatternist::XsdSchema::simpleTypes(), QPatternist::XsdSchema::types(), QDeclarativeSmoothedAnimationPrivate::updateRunningAnimations(), QPatternist::XsdSchemaResolver::XsdSchemaResolver(), and QDeclarativePixmapReader::~QDeclarativePixmapReader().

694 {
695  QList<T> res;
696  res.reserve(size());
697  const_iterator i = begin();
698  while (i != end()) {
699  res.append(i.value());
700  ++i;
701  }
702  return res;
703 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
friend class const_iterator
Definition: qhash.h:461
void reserve(int size)
Reserve space for alloc elements.
Definition: qlist.h:496
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ values() [2/2]

template<class Key, class T >
Q_OUTOFLINE_TEMPLATE QList< T > QHash< Key, T >::values ( const Key &  key) const

Returns a list of all the values associated with the key, from the most recently inserted to the least recently inserted.

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

See also
count(), insertMulti()

Definition at line 706 of file qhash.h.

707 {
708  QList<T> res;
709  Node *node = *findNode(akey);
710  if (node != e) {
711  do {
712  res.append(node->value);
713  } while ((node = node->next) != e && node->key == akey);
714  }
715  return res;
716 }
Node ** findNode(const Key &key, uint *hp=0) const
Definition: qhash.h:878
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QHashNode< Key, T > * e
Definition: qhash.h:265
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Friends and Related Functions

◆ const_iterator

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

Definition at line 461 of file qhash.h.

◆ iterator

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

Definition at line 393 of file qhash.h.

◆ operator<<()

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

377 {
378  out << quint32(hash.size());
379  typename QHash<Key, T>::ConstIterator it = hash.end();
380  typename QHash<Key, T>::ConstIterator begin = hash.begin();
381  while (it != begin) {
382  --it;
383  out << it.key() << it.value();
384  }
385  return out;
386 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
unsigned int quint32
Definition: qglobal.h:938
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464

◆ operator>>()

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

350 {
351  QDataStream::Status oldStatus = in.status();
352  in.resetStatus();
353  hash.clear();
354 
355  quint32 n;
356  in >> n;
357 
358  for (quint32 i = 0; i < n; ++i) {
359  if (in.status() != QDataStream::Ok)
360  break;
361 
362  Key k;
363  T t;
364  in >> k >> t;
365  hash.insertMulti(k, t);
366  }
367 
368  if (in.status() != QDataStream::Ok)
369  hash.clear();
370  if (oldStatus != QDataStream::Ok)
371  in.setStatus(oldStatus);
372  return in;
373 }
Status status() const
Returns the status of the data stream.
void clear()
Removes all items from the hash.
Definition: qhash.h:574
Status
This enum describes the current status of the data stream.
Definition: qdatastream.h:101
void setStatus(Status status)
Sets the status of the data stream to the status given.
void resetStatus()
Resets the status of the data stream.
unsigned int quint32
Definition: qglobal.h:938
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:772

◆ qHash() [1/17]

template<class Key, class T>
uint qHash ( const QPair< T1, T2 > &  key)
related

Returns the hash value for the key.

Since
4.3

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

Definition at line 105 of file qhash.h.

106 {
107  uint h1 = qHash(key.first);
108  uint h2 = qHash(key.second);
109  return ((h1 << 16) | (h1 >> 16)) ^ h2;
110 }
T1 first
Definition: qpair.h:65
T2 second
Definition: qpair.h:66
uint qHash(const QPair< T1, T2 > &key)
Returns the hash value for the key.
Definition: qhash.h:105
unsigned int uint
Definition: qglobal.h:996

◆ qHash() [2/17]

template<class Key, class T>
uint qHash ( char  key)
related

Returns the hash value for the key.

Definition at line 62 of file qhash.h.

62 { return uint(key); }
unsigned int uint
Definition: qglobal.h:996
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [3/17]

template<class Key, class T>
uint qHash ( uchar  key)
related

Returns the hash value for the key.

Definition at line 63 of file qhash.h.

63 { return uint(key); }
unsigned int uint
Definition: qglobal.h:996
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [4/17]

template<class Key, class T>
uint qHash ( signed char  key)
related

Returns the hash value for the key.

Definition at line 64 of file qhash.h.

64 { return uint(key); }
unsigned int uint
Definition: qglobal.h:996
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [5/17]

template<class Key, class T>
uint qHash ( ushort  key)
related

Returns the hash value for the key.

Definition at line 65 of file qhash.h.

65 { return uint(key); }
unsigned int uint
Definition: qglobal.h:996
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [6/17]

template<class Key, class T>
uint qHash ( short  key)
related

Returns the hash value for the key.

Definition at line 66 of file qhash.h.

66 { return uint(key); }
unsigned int uint
Definition: qglobal.h:996
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [7/17]

template<class Key, class T>
uint qHash ( uint  key)
related

Returns the hash value for the key.

Definition at line 67 of file qhash.h.

67 { return key; }
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [8/17]

template<class Key, class T>
uint qHash ( int  key)
related

Returns the hash value for the key.

Definition at line 68 of file qhash.h.

68 { return uint(key); }
unsigned int uint
Definition: qglobal.h:996
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [9/17]

template<class Key, class T>
uint qHash ( ulong  key)
related

Returns the hash value for the key.

Definition at line 69 of file qhash.h.

70 {
71  if (sizeof(ulong) > sizeof(uint)) {
72  return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U));
73  } else {
74  return uint(key & (~0U));
75  }
76 }
unsigned int uint
Definition: qglobal.h:996
unsigned long ulong
Definition: qglobal.h:997
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [10/17]

template<class Key, class T>
uint qHash ( long  key)
related

Returns the hash value for the key.

Definition at line 77 of file qhash.h.

77 { return qHash(ulong(key)); }
uint qHash(const QPair< T1, T2 > &key)
Returns the hash value for the key.
Definition: qhash.h:105
unsigned long ulong
Definition: qglobal.h:997
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [11/17]

template<class Key, class T>
uint qHash ( quint64  key)
related

Returns the hash value for the key.

Definition at line 78 of file qhash.h.

79 {
80  if (sizeof(quint64) > sizeof(uint)) {
81  return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U));
82  } else {
83  return uint(key & (~0U));
84  }
85 }
unsigned __int64 quint64
Definition: qglobal.h:943
unsigned int uint
Definition: qglobal.h:996
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [12/17]

template<class Key, class T>
uint qHash ( qint64  key)
related

Returns the hash value for the key.

Definition at line 86 of file qhash.h.

86 { return qHash(quint64(key)); }
uint qHash(const QPair< T1, T2 > &key)
Returns the hash value for the key.
Definition: qhash.h:105
unsigned __int64 quint64
Definition: qglobal.h:943
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [13/17]

template<class Key, class T>
uint qHash ( QChar  key)
related

Returns the hash value for the key.

Definition at line 87 of file qhash.h.

87 { return qHash(key.unicode()); }
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
uint qHash(const QPair< T1, T2 > &key)
Returns the hash value for the key.
Definition: qhash.h:105

◆ qHash() [14/17]

template<class Key, class T>
uint qHash ( const QBitArray key)
related

Definition at line 107 of file qhash.cpp.

108 {
109  int m = bitArray.d.size() - 1;
110  uint result = hash(reinterpret_cast<const uchar *>(bitArray.d.constData()), qMax(0, m));
111 
112  // deal with the last 0 to 7 bits manually, because we can't trust that
113  // the padding is initialized to 0 in bitArray.d
114  int n = bitArray.size();
115  if (n & 0x7)
116  result = ((result << 4) + bitArray.d.at(m)) & ((1 << n) - 1);
117  return result;
118 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
unsigned int uint
Definition: qglobal.h:996

◆ qHash() [15/17]

template<class Key, class T>
uint qHash ( const QString key)
related

Returns the hash value for the key.

Definition at line 97 of file qhash.cpp.

98 {
99  return hash(key.unicode(), key.size());
100 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ qHash() [16/17]

template<class Key, class T>
uint qHash ( const T *  key)
related

Returns the hash value for the key.

Definition at line 97 of file qhash.h.

98 {
99  return qHash(reinterpret_cast<quintptr>(key));
100 }
uint qHash(const QPair< T1, T2 > &key)
Returns the hash value for the key.
Definition: qhash.h:105
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674

◆ qHash() [17/17]

template<class Key, class T>
uint qHash ( const QXmlNodeModelIndex index)
related

Computes a hash key from the QXmlNodeModelIndex index, and returns it.

Since
4.4

This function would be used by QHash if you wanted to build a hash table for instances of QXmlNodeModelIndex.

The hash is computed on QXmlNodeModelIndex::data(), QXmlNodeModelIndex::additionalData(), and QXmlNodeModelIndex::model(). This means the hash key can be used for node indexes from different node models.

Definition at line 1447 of file qabstractxmlnodemodel.cpp.

1448 {
1449  return uint(index.data() + index.additionalData() + quintptr(index.model()));
1450 }
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
qint64 data() const
Returns the first data value.
unsigned int uint
Definition: qglobal.h:996
const QAbstractXmlNodeModel * model() const
Returns the QAbstractXmlNodeModel that this node index refers to.
qint64 additionalData() const
Returns the second data value.

Properties

◆ @55

union { ... }

◆ d

template<class Key, class T>
QHashData* QHash< Key, T >::d

◆ e

template<class Key, class T>
QHashNode<Key, T>* QHash< Key, T >::e

Definition at line 265 of file qhash.h.


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