diff options
Diffstat (limited to 'src/corelib/tools/qhash.h')
-rw-r--r-- | src/corelib/tools/qhash.h | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 59883e3968..c87cf56988 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -309,10 +309,10 @@ public: QList<Key> keys(const T &value) const; QList<T> values() const; #if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") QList<Key> uniqueKeys() const; - QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") QList<T> values(const Key &key) const; - QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") int count(const Key &key) const; + QT_DEPRECATED_VERSION_X_5_15("Use QMultiHash for hashes storing multiple values with the same key.") QList<Key> uniqueKeys() const; + QT_DEPRECATED_VERSION_X_5_15("Use QMultiHash for hashes storing multiple values with the same key.") QList<T> values(const Key &key) const; #endif + int count(const Key &key) const; class const_iterator; @@ -512,8 +512,8 @@ public: iterator insert(const Key &key, const T &value); void insert(const QHash &hash); #if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") iterator insertMulti(const Key &key, const T &value); - QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") QHash &unite(const QHash &other); + QT_DEPRECATED_VERSION_X_5_15("Use QMultiHash for hashes storing multiple values with the same key.") iterator insertMulti(const Key &key, const T &value); + QT_DEPRECATED_VERSION_X_5_15("Use QMultiHash for hashes storing multiple values with the same key.") QHash &unite(const QHash &other); #endif // STL compatibility @@ -711,6 +711,19 @@ Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values() const } template <class Key, class T> +Q_OUTOFLINE_TEMPLATE int QHash<Key, T>::count(const Key &akey) const +{ + int cnt = 0; + Node *node = *findNode(akey); + if (node != e) { + do { + ++cnt; + } while ((node = node->next) != e && node->key == akey); + } + return cnt; +} + +template <class Key, class T> Q_INLINE_TEMPLATE const T QHash<Key, T>::operator[](const Key &akey) const { return value(akey); @@ -1053,7 +1066,6 @@ public: int remove(const Key &key, const T &value); - int count(const Key &key) const; int count(const Key &key, const T &value) const; QList<Key> uniqueKeys() const; @@ -1207,12 +1219,6 @@ Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values(const Key &akey) const } template <class Key, class T> -Q_OUTOFLINE_TEMPLATE int QHash<Key, T>::count(const Key &akey) const -{ - return static_cast<const QMultiHash<Key, T> *>(this)->count(akey); -} - -template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::uniqueKeys() const { return static_cast<const QMultiHash<Key, T> *>(this)->uniqueKeys(); @@ -1232,19 +1238,6 @@ Q_OUTOFLINE_TEMPLATE QList<T> QMultiHash<Key, T>::values(const Key &akey) const return res; } -template <class Key, class T> -Q_OUTOFLINE_TEMPLATE int QMultiHash<Key, T>::count(const Key &akey) const -{ - int cnt = 0; - Node *node = *findNode(akey); - if (node != this->e) { - do { - ++cnt; - } while ((node = node->next) != this->e && node->key == akey); - } - return cnt; -} - #if !defined(QT_NO_JAVA_STYLE_ITERATORS) template <class Key, class T> class QHashIterator |