src/corelib/tools/qhash.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    62 */
    62 */
    63 
    63 
    64 static uint hash(const uchar *p, int n)
    64 static uint hash(const uchar *p, int n)
    65 {
    65 {
    66     uint h = 0;
    66     uint h = 0;
    67     uint g;
       
    68 
    67 
    69     while (n--) {
    68     while (n--) {
    70         h = (h << 4) + *p++;
    69         h = (h << 4) + *p++;
    71         g = h & 0xf0000000;
    70         h ^= (h & 0xf0000000) >> 23;
    72         h ^= g >> 23;
    71         h &= 0x0fffffff;
    73         h &= ~g;
       
    74     }
    72     }
    75     return h;
    73     return h;
    76 }
    74 }
    77 
    75 
    78 static uint hash(const QChar *p, int n)
    76 static uint hash(const QChar *p, int n)
    79 {
    77 {
    80     uint h = 0;
    78     uint h = 0;
    81     uint g;
       
    82 
    79 
    83     while (n--) {
    80     while (n--) {
    84         h = (h << 4) + (*p++).unicode();
    81         h = (h << 4) + (*p++).unicode();
    85         g = h & 0xf0000000;
    82         h ^= (h & 0xf0000000) >> 23;
    86         h ^= g >> 23;
    83         h &= 0x0fffffff;
    87         h &= ~g;
       
    88     }
    84     }
    89     return h;
    85     return h;
    90 }
    86 }
    91 
    87 
    92 uint qHash(const QByteArray &key)
    88 uint qHash(const QByteArray &key)
   845 /*! \fn void QHash::setSharable(bool sharable)
   841 /*! \fn void QHash::setSharable(bool sharable)
   846 
   842 
   847     \internal
   843     \internal
   848 */
   844 */
   849 
   845 
       
   846 /*! \fn bool QHash::isSharedWith(const QHash<Key, T> &other) const
       
   847 
       
   848     \internal
       
   849 */
       
   850 
   850 /*! \fn void QHash::clear()
   851 /*! \fn void QHash::clear()
   851 
   852 
   852     Removes all items from the hash.
   853     Removes all items from the hash.
   853 
   854 
   854     \sa remove()
   855     \sa remove()
  1663     Writes the hash \a hash to stream \a out.
  1664     Writes the hash \a hash to stream \a out.
  1664 
  1665 
  1665     This function requires the key and value types to implement \c
  1666     This function requires the key and value types to implement \c
  1666     operator<<().
  1667     operator<<().
  1667 
  1668 
  1668     \sa {Format of the QDataStream operators}
  1669     \sa {Serializing Qt Data Types}
  1669 */
  1670 */
  1670 
  1671 
  1671 /*! \fn QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash)
  1672 /*! \fn QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash)
  1672     \relates QHash
  1673     \relates QHash
  1673 
  1674 
  1674     Reads a hash from stream \a in into \a hash.
  1675     Reads a hash from stream \a in into \a hash.
  1675 
  1676 
  1676     This function requires the key and value types to implement \c
  1677     This function requires the key and value types to implement \c
  1677     operator>>().
  1678     operator>>().
  1678 
  1679 
  1679     \sa {Format of the QDataStream operators}
  1680     \sa {Serializing Qt Data Types}
  1680 */
  1681 */
  1681 
  1682 
  1682 /*! \class QMultiHash
  1683 /*! \class QMultiHash
  1683     \brief The QMultiHash class is a convenience QHash subclass that provides multi-valued hashes.
  1684     \brief The QMultiHash class is a convenience QHash subclass that provides multi-valued hashes.
  1684 
  1685