equal
deleted
inserted
replaced
297 inline void squeeze() { reserve(1); } |
297 inline void squeeze() { reserve(1); } |
298 |
298 |
299 inline void detach() { if (d->ref != 1) detach_helper(); } |
299 inline void detach() { if (d->ref != 1) detach_helper(); } |
300 inline bool isDetached() const { return d->ref == 1; } |
300 inline bool isDetached() const { return d->ref == 1; } |
301 inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } |
301 inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } |
|
302 inline bool isSharedWith(const QHash<Key, T> &other) const { return d == other.d; } |
302 |
303 |
303 void clear(); |
304 void clear(); |
304 |
305 |
305 int remove(const Key &key); |
306 int remove(const Key &key); |
306 T take(const Key &key); |
307 T take(const Key &key); |
622 |
623 |
623 template <class Key, class T> |
624 template <class Key, class T> |
624 Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::uniqueKeys() const |
625 Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::uniqueKeys() const |
625 { |
626 { |
626 QList<Key> res; |
627 QList<Key> res; |
|
628 res.reserve(size()); // May be too much, but assume short lifetime |
627 const_iterator i = begin(); |
629 const_iterator i = begin(); |
628 if (i != end()) { |
630 if (i != end()) { |
629 for (;;) { |
631 for (;;) { |
630 const Key &aKey = i.key(); |
632 const Key &aKey = i.key(); |
631 res.append(aKey); |
633 res.append(aKey); |
641 |
643 |
642 template <class Key, class T> |
644 template <class Key, class T> |
643 Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::keys() const |
645 Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::keys() const |
644 { |
646 { |
645 QList<Key> res; |
647 QList<Key> res; |
|
648 res.reserve(size()); |
646 const_iterator i = begin(); |
649 const_iterator i = begin(); |
647 while (i != end()) { |
650 while (i != end()) { |
648 res.append(i.key()); |
651 res.append(i.key()); |
649 ++i; |
652 ++i; |
650 } |
653 } |
685 |
688 |
686 template <class Key, class T> |
689 template <class Key, class T> |
687 Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values() const |
690 Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values() const |
688 { |
691 { |
689 QList<T> res; |
692 QList<T> res; |
|
693 res.reserve(size()); |
690 const_iterator i = begin(); |
694 const_iterator i = begin(); |
691 while (i != end()) { |
695 while (i != end()) { |
692 res.append(i.value()); |
696 res.append(i.value()); |
693 ++i; |
697 ++i; |
694 } |
698 } |
925 |
929 |
926 inline typename QHash<Key, T>::iterator insert(const Key &key, const T &value) |
930 inline typename QHash<Key, T>::iterator insert(const Key &key, const T &value) |
927 { return QHash<Key, T>::insertMulti(key, value); } |
931 { return QHash<Key, T>::insertMulti(key, value); } |
928 |
932 |
929 inline QMultiHash &operator+=(const QMultiHash &other) |
933 inline QMultiHash &operator+=(const QMultiHash &other) |
930 { this->unite(other); return *this; } |
934 { unite(other); return *this; } |
931 inline QMultiHash operator+(const QMultiHash &other) const |
935 inline QMultiHash operator+(const QMultiHash &other) const |
932 { QMultiHash result = *this; result += other; return result; } |
936 { QMultiHash result = *this; result += other; return result; } |
933 |
937 |
934 #if !defined(Q_NO_USING_KEYWORD) && !defined(Q_CC_RVCT) |
938 #if !defined(Q_NO_USING_KEYWORD) && !defined(Q_CC_RVCT) |
935 // RVCT compiler doesn't handle using-keyword right when used functions are overloaded in child class |
939 // RVCT compiler doesn't handle using-keyword right when used functions are overloaded in child class |
1000 int n = 0; |
1004 int n = 0; |
1001 typename QHash<Key, T>::iterator i(find(key)); |
1005 typename QHash<Key, T>::iterator i(find(key)); |
1002 typename QHash<Key, T>::iterator end(QHash<Key, T>::end()); |
1006 typename QHash<Key, T>::iterator end(QHash<Key, T>::end()); |
1003 while (i != end && i.key() == key) { |
1007 while (i != end && i.key() == key) { |
1004 if (i.value() == value) { |
1008 if (i.value() == value) { |
1005 i = this->erase(i); |
1009 #if defined(Q_CC_RVCT) |
|
1010 // RVCT has problems with scoping, apparently. |
|
1011 i = QHash<Key, T>::erase(i); |
|
1012 #else |
|
1013 i = erase(i); |
|
1014 #endif |
1006 ++n; |
1015 ++n; |
1007 } else { |
1016 } else { |
1008 ++i; |
1017 ++i; |
1009 } |
1018 } |
1010 } |
1019 } |