74 h ^= (h & 0xf0000000) >> 23;
85 h = (h << 4) + (*p++).unicode();
86 h ^= (h & 0xf0000000) >> 23;
109 int m = bitArray.
d.
size() - 1;
114 int n = bitArray.
size();
116 result = ((result << 4) + bitArray.
d.
at(m)) & ((1 << n) - 1);
131 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3,
132 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0
169 0, 0,
Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0,
MinNumBits, 0, 0,
true,
false, 0
198 void (*node_delete)(
Node *),
216 d->strictAlignment = nodeAlign > 8;
226 d->free_helper(node_delete);
230 Node *this_e =
reinterpret_cast<Node *
>(
this);
234 while (oldNode != this_e) {
239 node_duplicate(oldNode, dup);
247 nextNode = &dup->
next;
248 oldNode = oldNode->
next;
254 d->free_helper(node_delete);
267 Node *this_e =
reinterpret_cast<Node *
>(
this);
272 Node *cur = *bucket++;
273 while (cur != this_e) {
293 Q_ASSERT_X(next,
"QHash",
"Iterating beyond end()");
297 int start = (node->
h %
d->numBuckets) + 1;
298 Node **bucket =
d->buckets + start;
299 int n =
d->numBuckets - start;
321 start =
d->numBuckets - 1;
323 start = node->
h %
d->numBuckets;
325 Node *sentinel = node;
326 Node **bucket =
d->buckets + start;
328 if (*bucket != sentinel) {
329 Node *prev = *bucket;
330 while (prev->
next != sentinel)
339 Q_ASSERT_X(start >= 0,
"QHash",
"Iterating backward beyond begin()");
363 Node *e =
reinterpret_cast<Node *
>(
this);
374 for (
int i = 0; i < oldNumBuckets; ++i) {
376 while (firstNode != e) {
377 uint h = firstNode->
h;
379 while (lastNode->
next != e && lastNode->
next->
h == h)
380 lastNode = lastNode->
next;
382 Node *afterLastNode = lastNode->
next;
384 while (*beforeFirstNode != e)
385 beforeFirstNode = &(*beforeFirstNode)->
next;
386 lastNode->
next = *beforeFirstNode;
388 firstNode = afterLastNode;
391 delete [] oldBuckets;
400 #ifdef QT_QHASH_DEBUG 404 qDebug(
"Hash data (ref = %d, size = %d, nodeSize = %d, userNumBits = %d, numBits = %d, numBuckets = %d)",
411 if (n != reinterpret_cast<Node *>(
this)) {
413 while (n != reinterpret_cast<Node *>(
this)) {
416 line +=
" (CORRUPT)";
426 void QHashData::checkSanity()
429 qFatal(
"Fake next isn't 0");
435 qFatal(
"%d: Bucket entry is 0", i);
436 if (n != reinterpret_cast<Node *>(
this)) {
437 while (n != reinterpret_cast<Node *>(
this)) {
439 qFatal(
"%d: Next of %p is 0, should be %p", i, n,
this);
static uint hash(const uchar *p, int n)
QString & sprintf(const char *format,...)
Safely builds a formatted string from the format string cformat and an arbitrary list of arguments...
#define QT_END_NAMESPACE
This macro expands to.
Q_CORE_EXPORT void * qMallocAligned(size_t size, size_t alignment)
static Node * previousNode(Node *node)
Q_CORE_EXPORT void qFree(void *ptr)
The QByteArray class provides an array of bytes.
QHashData * detach_helper(void(*node_duplicate)(Node *, void *), int nodeSize)
QHashData * detach_helper2(void(*node_duplicate)(Node *, void *), void(*node_delete)(Node *), int nodeSize, int nodeAlign)
static Node * nextNode(Node *node)
Q_CORE_EXPORT void * qMalloc(size_t size)
The QString class provides a Unicode character string.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
The QChar class provides a 16-bit Unicode character.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
static int countBits(int hint)
Q_CORE_EXPORT void qDebug(const char *,...)
int size() const
Returns the number of characters referred to by the string reference.
#define QT_BEGIN_NAMESPACE
This macro expands to.
int size() const
Returns the number of characters in this string.
const QChar * unicode() const
Returns a '\0'-terminated Unicode representation of the string.
const QChar * unicode() const
Returns a Unicode representation of the string reference.
const T * ptr(const T &t)
void free_helper(void(*node_delete)(Node *))
static QHashData shared_null
The QStringRef class provides a thin wrapper around QString substrings.
The QBitArray class provides an array of bits.
const char * constData() const
Returns a pointer to the data stored in the byte array.
Q_CORE_EXPORT void qFatal(const char *,...)
uint qHash(const QUrl &url)
#define Q_ASSERT_X(cond, where, what)
static const uchar prime_deltas[]
static QString dump(const QByteArray &)
int size() const
Returns the number of bytes in this byte array.
void freeNode(void *node)
static int primeForNumBits(int numBits)
char at(int i) const
Returns the character at index position i in the byte array.
#define qPrintable(string)
int size() const
Returns the number of bits stored in the bit array.
Q_CORE_EXPORT void qFreeAligned(void *ptr)