diff options
Diffstat (limited to 'src/corelib/tools/qhash.h')
-rw-r--r-- | src/corelib/tools/qhash.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 703066857d..ce663ce2ca 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -315,7 +315,7 @@ public: typedef T *pointer; typedef T &reference; - inline iterator() : i(Q_NULLPTR) { } + inline iterator() : i(nullptr) { } explicit inline iterator(void *node) : i(reinterpret_cast<QHashData::Node *>(node)) { } inline const Key &key() const { return concrete(i)->key; } @@ -373,7 +373,7 @@ public: typedef const T *pointer; typedef const T &reference; - Q_DECL_CONSTEXPR inline const_iterator() : i(Q_NULLPTR) { } + Q_DECL_CONSTEXPR inline const_iterator() : i(nullptr) { } explicit inline const_iterator(void *node) : i(reinterpret_cast<QHashData::Node *>(node)) { } #ifdef QT_STRICT_ITERATORS @@ -449,6 +449,9 @@ public: const_iterator base() const { return i; } }; + typedef QKeyValueIterator<const Key&, const T&, const_iterator> const_key_value_iterator; + typedef QKeyValueIterator<const Key&, T&, iterator> key_value_iterator; + // STL style inline iterator begin() { detach(); return iterator(d->firstNode()); } inline const_iterator begin() const { return const_iterator(d->firstNode()); } @@ -460,6 +463,12 @@ public: inline const_iterator constEnd() const { return const_iterator(e); } inline key_iterator keyBegin() const { return key_iterator(begin()); } inline key_iterator keyEnd() const { return key_iterator(end()); } + inline key_value_iterator keyValueBegin() { return key_value_iterator(begin()); } + inline key_value_iterator keyValueEnd() { return key_value_iterator(end()); } + inline const_key_value_iterator keyValueBegin() const { return const_key_value_iterator(begin()); } + inline const_key_value_iterator constKeyValueBegin() const { return const_key_value_iterator(begin()); } + inline const_key_value_iterator keyValueEnd() const { return const_key_value_iterator(end()); } + inline const_key_value_iterator constKeyValueEnd() const { return const_key_value_iterator(end()); } QPair<iterator, iterator> equal_range(const Key &key); QPair<const_iterator, const_iterator> equal_range(const Key &key) const Q_DECL_NOTHROW; @@ -493,7 +502,7 @@ public: private: void detach_helper(); void freeData(QHashData *d); - Node **findNode(const Key &key, uint *hp = Q_NULLPTR) const; + Node **findNode(const Key &key, uint *hp = nullptr) const; Node **findNode(const Key &key, uint h) const; Node *createNode(uint h, const Key &key, const T &value, Node **nextNode); void deleteNode(Node *node); @@ -541,7 +550,7 @@ template <class Key, class T> Q_INLINE_TEMPLATE void QHash<Key, T>::duplicateNode(QHashData::Node *node, void *newNode) { Node *concreteNode = concrete(node); - new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, Q_NULLPTR); + new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, nullptr); } template <class Key, class T> @@ -816,7 +825,7 @@ Q_OUTOFLINE_TEMPLATE T QHash<Key, T>::take(const Key &akey) Node **node = findNode(akey); if (*node != e) { - T t = (*node)->value; + T t = std::move((*node)->value); Node *next = (*node)->next; deleteNode(*node); *node = next; @@ -960,7 +969,7 @@ Q_OUTOFLINE_TEMPLATE bool QHash<Key, T>::operator==(const QHash &other) const // // ### Qt 6: if C++14 library support is a mandated minimum, remove the ifdef for MSVC. if (!std::is_permutation(it, thisEqualRangeEnd, otherEqualRange.first -#if defined(Q_CC_MSVC) && _MSC_VER >= 1900 +#ifdef Q_CC_MSVC , otherEqualRange.second #endif )) { |