summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qmap.cpp38
-rw-r--r--src/corelib/tools/qmap.h56
2 files changed, 47 insertions, 47 deletions
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index e2582ccdf4..1dcbaeec94 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -301,7 +301,7 @@ void QMapDataBase::recalcMostLeftNode()
mostLeftNode = mostLeftNode->left;
}
-static inline int qMapAlignmentThreshold()
+static inline size_t qMapAlignmentThreshold()
{
// malloc on 32-bit platforms should return pointers that are 8-byte
// aligned or more while on 64-bit platforms they should be 16-byte aligned
@@ -309,14 +309,14 @@ static inline int qMapAlignmentThreshold()
return 2 * sizeof(void*);
}
-static inline void *qMapAllocate(int alloc, int alignment)
+static inline void *qMapAllocate(size_t alloc, size_t alignment)
{
return alignment > qMapAlignmentThreshold()
? qMallocAligned(alloc, alignment)
: ::malloc(alloc);
}
-static inline void qMapDeallocate(QMapNodeBase *node, int alignment)
+static inline void qMapDeallocate(QMapNodeBase *node, size_t alignment)
{
if (alignment > qMapAlignmentThreshold())
qFreeAligned(node);
@@ -324,7 +324,7 @@ static inline void qMapDeallocate(QMapNodeBase *node, int alignment)
::free(node);
}
-QMapNodeBase *QMapDataBase::createNode(int alloc, int alignment, QMapNodeBase *parent, bool left)
+QMapNodeBase *QMapDataBase::createNode(size_t alloc, size_t alignment, QMapNodeBase *parent, bool left)
{
QMapNodeBase *node = static_cast<QMapNodeBase *>(qMapAllocate(alloc, alignment));
Q_CHECK_PTR(node);
@@ -346,7 +346,7 @@ QMapNodeBase *QMapDataBase::createNode(int alloc, int alignment, QMapNodeBase *p
return node;
}
-void QMapDataBase::freeTree(QMapNodeBase *root, int alignment)
+void QMapDataBase::freeTree(QMapNodeBase *root, size_t alignment)
{
if (root->left)
freeTree(root->left, alignment);
@@ -619,7 +619,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator==()
*/
-/*! \fn template <class Key, class T> int QMap<Key, T>::size() const
+/*! \fn template <class Key, class T> qsizetype QMap<Key, T>::size() const
Returns the number of (key, value) pairs in the map.
@@ -672,7 +672,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa remove()
*/
-/*! \fn template <class Key, class T> int QMap<Key, T>::remove(const Key &key)
+/*! \fn template <class Key, class T> qsizetype QMap<Key, T>::remove(const Key &key)
Removes all the items that have the key \a key from the map.
Returns the number of items removed which will be 1 if the key
@@ -813,14 +813,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMultiMap::values()
*/
-/*! \fn template <class Key, class T> int QMap<Key, T>::count(const Key &key) const
+/*! \fn template <class Key, class T> qsizetype QMap<Key, T>::count(const Key &key) const
Returns the number of items associated with key \a key.
\sa contains(), QMultiMap::count()
*/
-/*! \fn template <class Key, class T> int QMap<Key, T>::count() const
+/*! \fn template <class Key, class T> qsizetype QMap<Key, T>::count() const
\overload
@@ -1467,7 +1467,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator+(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator+(qsizetype j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1478,7 +1478,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
-/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator-(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator-(qsizetype j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1488,7 +1488,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator+()
*/
-/*! \fn template <class Key, class T> QMap<Key, T>::iterator &QMap<Key, T>::iterator::operator+=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator &QMap<Key, T>::iterator::operator+=(qsizetype j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1496,7 +1496,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-=(), operator+()
*/
-/*! \fn template <class Key, class T> QMap<Key, T>::iterator &QMap<Key, T>::iterator::operator-=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator &QMap<Key, T>::iterator::operator-=(qsizetype j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1681,7 +1681,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator+(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator+(qsizetype j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1691,7 +1691,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-()
*/
-/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator-(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator-(qsizetype j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1701,7 +1701,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator+()
*/
-/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator+=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator+=(qsizetype j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1711,7 +1711,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-=(), operator+()
*/
-/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator-=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator-=(qsizetype j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -2043,7 +2043,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn template <class Key, class T> int QMultiMap<Key, T>::remove(const Key &key, const T &value)
+ \fn template <class Key, class T> qsizetype QMultiMap<Key, T>::remove(const Key &key, const T &value)
\since 4.3
Removes all the items that have the key \a key and the value \a
@@ -2053,7 +2053,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn template <class Key, class T> int QMultiMap<Key, T>::count(const Key &key, const T &value) const
+ \fn template <class Key, class T> qsizetype QMultiMap<Key, T>::count(const Key &key, const T &value) const
\since 4.3
Returns the number of items with key \a key and value \a value.
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index be8ba6c4ba..848ba5c4d4 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -180,7 +180,7 @@ inline QMapNode<Key, T> *QMapNode<Key, T>::upperBound(const Key &akey)
struct Q_CORE_EXPORT QMapDataBase
{
QtPrivate::RefCount ref;
- int size;
+ qsizetype size;
QMapNodeBase header;
QMapNodeBase *mostLeftNode;
@@ -190,8 +190,8 @@ struct Q_CORE_EXPORT QMapDataBase
void freeNodeAndRebalance(QMapNodeBase *z);
void recalcMostLeftNode();
- QMapNodeBase *createNode(int size, int alignment, QMapNodeBase *parent, bool left);
- void freeTree(QMapNodeBase *root, int alignment);
+ QMapNodeBase *createNode(size_t size, size_t alignment, QMapNodeBase *parent, bool left);
+ void freeTree(QMapNodeBase *root, size_t alignment);
static const QMapDataBase shared_null;
@@ -350,7 +350,7 @@ public:
bool operator==(const QMap<Key, T> &other) const;
inline bool operator!=(const QMap<Key, T> &other) const { return !(*this == other); }
- inline int size() const { return d->size; }
+ inline qsizetype size() const { return d->size; }
inline bool isEmpty() const { return d->size == 0; }
@@ -360,7 +360,7 @@ public:
void clear();
- int remove(const Key &key);
+ qsizetype remove(const Key &key);
T take(const Key &key);
bool contains(const Key &key) const;
@@ -376,7 +376,7 @@ public:
QT_DEPRECATED_VERSION_X_5_15("Use QMultiMap for maps storing multiple values with the same key.") QList<Key> uniqueKeys() const;
QT_DEPRECATED_VERSION_X_5_15("Use QMultiMap for maps storing multiple values with the same key.") QList<T> values(const Key &key) const;
#endif
- int count(const Key &key) const;
+ qsizetype count(const Key &key) const;
inline const Key &firstKey() const { Q_ASSERT(!isEmpty()); return constBegin().key(); }
@@ -429,12 +429,12 @@ public:
i = i->previousNode();
return r;
}
- inline iterator operator+(int j) const
+ inline iterator operator+(qsizetype j) const
{ iterator r = *this; if (j > 0) while (j--) ++r; else while (j++) --r; return r; }
- inline iterator operator-(int j) const { return operator+(-j); }
- inline iterator &operator+=(int j) { return *this = *this + j; }
- inline iterator &operator-=(int j) { return *this = *this - j; }
- friend inline iterator operator+(int j, iterator k) { return k + j; }
+ inline iterator operator-(qsizetype j) const { return operator+(-j); }
+ inline iterator &operator+=(qsizetype j) { return *this = *this + j; }
+ inline iterator &operator-=(qsizetype j) { return *this = *this - j; }
+ friend inline iterator operator+(qsizetype j, iterator k) { return k + j; }
inline bool operator==(const const_iterator &o) const { return i == o.i; }
inline bool operator!=(const const_iterator &o) const { return i != o.i; }
@@ -484,12 +484,12 @@ public:
i = i->previousNode();
return r;
}
- inline const_iterator operator+(int j) const
+ inline const_iterator operator+(qsizetype j) const
{ const_iterator r = *this; if (j > 0) while (j--) ++r; else while (j++) --r; return r; }
- inline const_iterator operator-(int j) const { return operator+(-j); }
- inline const_iterator &operator+=(int j) { return *this = *this + j; }
- inline const_iterator &operator-=(int j) { return *this = *this - j; }
- friend inline const_iterator operator+(int j, const_iterator k) { return k + j; }
+ inline const_iterator operator-(qsizetype j) const { return operator+(-j); }
+ inline const_iterator &operator+=(qsizetype j) { return *this = *this + j; }
+ inline const_iterator &operator-=(qsizetype j) { return *this = *this - j; }
+ friend inline const_iterator operator+(qsizetype j, const_iterator k) { return k + j; }
friend class QMap<Key, T>;
friend class QMultiMap<Key, T>;
@@ -547,7 +547,7 @@ public:
// more Qt
typedef iterator Iterator;
typedef const_iterator ConstIterator;
- inline int count() const { return d->size; }
+ inline qsizetype count() const { return d->size; }
iterator find(const Key &key);
const_iterator find(const Key &key) const;
const_iterator constFind(const Key &key) const;
@@ -568,7 +568,7 @@ public:
typedef Key key_type;
typedef T mapped_type;
typedef qptrdiff difference_type;
- typedef int size_type;
+ typedef qsizetype size_type;
inline bool empty() const { return isEmpty(); }
QPair<iterator, iterator> equal_range(const Key &akey);
QPair<const_iterator, const_iterator> equal_range(const Key &akey) const;
@@ -655,7 +655,7 @@ Q_INLINE_TEMPLATE T &QMap<Key, T>::operator[](const Key &akey)
}
template <class Key, class T>
-Q_INLINE_TEMPLATE int QMap<Key, T>::count(const Key &akey) const
+Q_INLINE_TEMPLATE qsizetype QMap<Key, T>::count(const Key &akey) const
{
Node *firstNode;
Node *lastNode;
@@ -878,10 +878,10 @@ void QMap<Key, T>::dump() const
#endif
template <class Key, class T>
-Q_OUTOFLINE_TEMPLATE int QMap<Key, T>::remove(const Key &akey)
+Q_OUTOFLINE_TEMPLATE qsizetype QMap<Key, T>::remove(const Key &akey)
{
detach();
- int n = 0;
+ qsizetype n = 0;
while (Node *node = d->findNode(akey)) {
d->deleteNode(node);
++n;
@@ -914,7 +914,7 @@ Q_OUTOFLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::erase(iterato
if (d->ref.isShared()) {
const_iterator oldBegin = constBegin();
const_iterator old = const_iterator(it);
- int backStepsWithSameKey = 0;
+ qsizetype backStepsWithSameKey = 0;
while (old != oldBegin) {
--old;
@@ -1131,9 +1131,9 @@ public:
bool contains(const Key &key, const T &value) const;
- int remove(const Key &key, const T &value);
+ qsizetype remove(const Key &key, const T &value);
- int count(const Key &key, const T &value) const;
+ qsizetype count(const Key &key, const T &value) const;
typename QMap<Key, T>::iterator find(const Key &key, const T &value) {
typename QMap<Key, T>::iterator i(find(key));
@@ -1289,9 +1289,9 @@ Q_INLINE_TEMPLATE bool QMultiMap<Key, T>::contains(const Key &key, const T &valu
}
template <class Key, class T>
-Q_INLINE_TEMPLATE int QMultiMap<Key, T>::remove(const Key &key, const T &value)
+Q_INLINE_TEMPLATE qsizetype QMultiMap<Key, T>::remove(const Key &key, const T &value)
{
- int n = 0;
+ qsizetype n = 0;
typename QMap<Key, T>::iterator i(find(key));
typename QMap<Key, T>::iterator end(QMap<Key, T>::end());
while (i != end && !qMapLessThanKey<Key>(key, i.key())) {
@@ -1306,9 +1306,9 @@ Q_INLINE_TEMPLATE int QMultiMap<Key, T>::remove(const Key &key, const T &value)
}
template <class Key, class T>
-Q_INLINE_TEMPLATE int QMultiMap<Key, T>::count(const Key &key, const T &value) const
+Q_INLINE_TEMPLATE qsizetype QMultiMap<Key, T>::count(const Key &key, const T &value) const
{
- int n = 0;
+ qsizetype n = 0;
typename QMap<Key, T>::const_iterator i(constFind(key));
typename QMap<Key, T>::const_iterator end(QMap<Key, T>::constEnd());
while (i != end && !qMapLessThanKey<Key>(key, i.key())) {