0, 0, Q_REFCOUNT_INITIALIZER(-1), 0, 0, MinNumBits, 0, 0, true, false, 0
};
-void *QHashData::allocateNode()
-{
- return allocateNode(0);
-}
-
void *QHashData::allocateNode(int nodeAlign)
{
void *ptr = strictAlignment ? qMallocAligned(nodeSize, nodeAlign) : qMalloc(nodeSize);
qFree(node);
}
-QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize)
-{
- return detach_helper2( node_duplicate, 0, nodeSize, 0 );
-}
-
-QHashData *QHashData::detach_helper2(void (*node_duplicate)(Node *, void *),
- void (*node_delete)(Node *),
- int nodeSize,
- int nodeAlign)
+QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
+ void (*node_delete)(Node *),
+ int nodeSize,
+ int nodeAlign)
{
union {
QHashData *d;
}
}
-void QHashData::destroyAndFree()
-{
- free_helper(0);
-}
-
#ifdef QT_QHASH_DEBUG
void QHashData::dump()
uint strictAlignment : 1;
uint reserved : 30;
- void *allocateNode(); // ### Qt5 remove me
void *allocateNode(int nodeAlign);
void freeNode(void *node);
- QHashData *detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize); // ### Qt5 remove me
- QHashData *detach_helper2(void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *),
- int nodeSize, int nodeAlign);
- void mightGrow();
+ QHashData *detach_helper(void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *),
+ int nodeSize, int nodeAlign);
bool willGrow();
void hasShrunk();
void rehash(int hint);
void free_helper(void (*node_delete)(Node *));
- void destroyAndFree(); // ### Qt5 remove me
Node *firstNode();
#ifdef QT_QHASH_DEBUG
void dump();
static const QHashData shared_null;
};
-inline void QHashData::mightGrow() // ### Qt 5: eliminate
-{
- if (size >= numBuckets)
- rehash(numBits + 1);
-}
-
inline bool QHashData::willGrow()
{
if (size >= numBuckets) {
Key key;
T value;
- inline QHashNode(const Key &key0) : key(key0) {} // ### remove in 5.0
inline QHashNode(const Key &key0, const T &value0) : key(key0), value(value0) {}
inline bool same_key(uint h0, const Key &key0) { return h0 == h && key0 == key; }
};
class iterator
{
friend class const_iterator;
+ friend class QHash<Key, T>;
QHashData::Node *i;
public:
typedef T *pointer;
typedef T &reference;
- // ### Qt 5: get rid of 'operator Node *'
- inline operator Node *() const { return concrete(i); }
inline iterator() : i(0) { }
explicit inline iterator(void *node) : i(reinterpret_cast<QHashData::Node *>(node)) { }
{ return i == o.i; }
inline bool operator!=(const const_iterator &o) const
{ return i != o.i; }
-
- private:
- // ### Qt 5: remove
- inline operator bool() const { return false; }
};
friend class iterator;
typedef const T *pointer;
typedef const T &reference;
- // ### Qt 5: get rid of 'operator Node *'
- inline operator Node *() const { return concrete(i); }
inline const_iterator() : i(0) { }
explicit inline const_iterator(void *node)
: i(reinterpret_cast<QHashData::Node *>(node)) { }
inline bool operator==(const iterator &o) const { return operator==(const_iterator(o)); }
inline bool operator!=(const iterator &o) const { return operator!=(const_iterator(o)); }
#endif
-
- private:
- // ### Qt 5: remove
- inline operator bool() const { return false; }
};
friend class const_iterator;
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE void QHash<Key, T>::detach_helper()
{
- QHashData *x = d->detach_helper2(duplicateNode, deleteNode2,
+ QHashData *x = d->detach_helper(duplicateNode, deleteNode2,
QTypeInfo<T>::isDummy ? sizeof(DummyNode) : sizeof(Node),
QTypeInfo<T>::isDummy ? alignOfDummyNode() : alignOfNode());
if (!d->ref.deref())
iterator ret = it;
++ret;
- Node *node = it;
+ Node *node = concrete(it.i);
Node **node_ptr = reinterpret_cast<Node **>(&d->buckets[node->h % d->numBuckets]);
while (*node_ptr != node)
node_ptr = &(*node_ptr)->next;