QMap/QHash: s/QPair/std::pair/
Also port from qMakePair to just braced initialization using CTAD. Task-number: QTBUG-115841 Change-Id: Ib0ad55d7110521e34004dc9050022f9c0046722e Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit 0d1575828015f99a495af84fb7de3746c7f61717) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
8cba66e91d
commit
cab0d26c45
@ -1783,8 +1783,8 @@ size_t qHash(long double key, size_t seed) noexcept
|
|||||||
|
|
||||||
Constructs a hash with a copy of each of the elements in the iterator range
|
Constructs a hash with a copy of each of the elements in the iterator range
|
||||||
[\a begin, \a end). Either the elements iterated by the range must be
|
[\a begin, \a end). Either the elements iterated by the range must be
|
||||||
objects with \c{first} and \c{second} data members (like \c{QPair},
|
objects with \c{first} and \c{second} data members (like \c{std::pair}),
|
||||||
\c{std::pair}, etc.) convertible to \c Key and to \c T respectively; or the
|
convertible to \c Key and to \c T respectively; or the
|
||||||
iterators must have \c{key()} and \c{value()} member functions, returning a
|
iterators must have \c{key()} and \c{value()} member functions, returning a
|
||||||
key convertible to \c Key and a value convertible to \c T respectively.
|
key convertible to \c Key and a value convertible to \c T respectively.
|
||||||
*/
|
*/
|
||||||
@ -2362,7 +2362,7 @@ size_t qHash(long double key, size_t seed) noexcept
|
|||||||
returns \c false.
|
returns \c false.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \fn template <class Key, class T> QPair<iterator, iterator> QMultiHash<Key, T>::equal_range(const Key &key)
|
/*! \fn template <class Key, class T> std::pair<iterator, iterator> QMultiHash<Key, T>::equal_range(const Key &key)
|
||||||
\since 5.7
|
\since 5.7
|
||||||
|
|
||||||
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
|
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
|
||||||
@ -2370,7 +2370,7 @@ size_t qHash(long double key, size_t seed) noexcept
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <class Key, class T> QPair<const_iterator, const_iterator> QMultiHash<Key, T>::equal_range(const Key &key) const
|
\fn template <class Key, class T> std::pair<const_iterator, const_iterator> QMultiHash<Key, T>::equal_range(const Key &key) const
|
||||||
\overload
|
\overload
|
||||||
\since 5.7
|
\since 5.7
|
||||||
*/
|
*/
|
||||||
@ -2955,8 +2955,8 @@ size_t qHash(long double key, size_t seed) noexcept
|
|||||||
|
|
||||||
Constructs a multi-hash with a copy of each of the elements in the iterator range
|
Constructs a multi-hash with a copy of each of the elements in the iterator range
|
||||||
[\a begin, \a end). Either the elements iterated by the range must be
|
[\a begin, \a end). Either the elements iterated by the range must be
|
||||||
objects with \c{first} and \c{second} data members (like \c{QPair},
|
objects with \c{first} and \c{second} data members (like \c{std::pair}),
|
||||||
\c{std::pair}, etc.) convertible to \c Key and to \c T respectively; or the
|
convertible to \c Key and to \c T respectively; or the
|
||||||
iterators must have \c{key()} and \c{value()} member functions, returning a
|
iterators must have \c{key()} and \c{value()} member functions, returning a
|
||||||
key convertible to \c Key and a value convertible to \c T respectively.
|
key convertible to \c Key and a value convertible to \c T respectively.
|
||||||
*/
|
*/
|
||||||
|
@ -1234,22 +1234,22 @@ public:
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<iterator, iterator> equal_range(const Key &key)
|
std::pair<iterator, iterator> equal_range(const Key &key)
|
||||||
{
|
{
|
||||||
auto first = find(key);
|
auto first = find(key);
|
||||||
auto second = first;
|
auto second = first;
|
||||||
if (second != iterator())
|
if (second != iterator())
|
||||||
++second;
|
++second;
|
||||||
return qMakePair(first, second);
|
return {first, second};
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
|
std::pair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
|
||||||
{
|
{
|
||||||
auto first = find(key);
|
auto first = find(key);
|
||||||
auto second = first;
|
auto second = first;
|
||||||
if (second != iterator())
|
if (second != iterator())
|
||||||
++second;
|
++second;
|
||||||
return qMakePair(first, second);
|
return {first, second};
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef iterator Iterator;
|
typedef iterator Iterator;
|
||||||
@ -2125,26 +2125,26 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<iterator, iterator> equal_range(const Key &key)
|
std::pair<iterator, iterator> equal_range(const Key &key)
|
||||||
{
|
{
|
||||||
const auto copy = isDetached() ? QMultiHash() : *this; // keep 'key' alive across the detach
|
const auto copy = isDetached() ? QMultiHash() : *this; // keep 'key' alive across the detach
|
||||||
detach();
|
detach();
|
||||||
auto pair = std::as_const(*this).equal_range(key);
|
auto pair = std::as_const(*this).equal_range(key);
|
||||||
return qMakePair(iterator(pair.first.i), iterator(pair.second.i));
|
return {iterator(pair.first.i), iterator(pair.second.i)};
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
|
std::pair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
|
||||||
{
|
{
|
||||||
if (!d)
|
if (!d)
|
||||||
return qMakePair(end(), end());
|
return {end(), end()};
|
||||||
|
|
||||||
auto bucket = d->findBucket(key);
|
auto bucket = d->findBucket(key);
|
||||||
if (bucket.isUnused())
|
if (bucket.isUnused())
|
||||||
return qMakePair(end(), end());
|
return {end(), end()};
|
||||||
auto it = bucket.toIterator(d);
|
auto it = bucket.toIterator(d);
|
||||||
auto end = it;
|
auto end = it;
|
||||||
++end;
|
++end;
|
||||||
return qMakePair(const_iterator(it), const_iterator(end));
|
return {const_iterator(it), const_iterator(end)};
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -762,7 +762,7 @@ public:
|
|||||||
return isEmpty();
|
return isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<iterator, iterator> equal_range(const Key &akey)
|
std::pair<iterator, iterator> equal_range(const Key &akey)
|
||||||
{
|
{
|
||||||
const auto copy = d.isShared() ? *this : QMap(); // keep `key` alive across the detach
|
const auto copy = d.isShared() ? *this : QMap(); // keep `key` alive across the detach
|
||||||
detach();
|
detach();
|
||||||
@ -770,7 +770,7 @@ public:
|
|||||||
return {iterator(result.first), iterator(result.second)};
|
return {iterator(result.first), iterator(result.second)};
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<const_iterator, const_iterator> equal_range(const Key &akey) const
|
std::pair<const_iterator, const_iterator> equal_range(const Key &akey) const
|
||||||
{
|
{
|
||||||
if (!d)
|
if (!d)
|
||||||
return {};
|
return {};
|
||||||
@ -1492,7 +1492,7 @@ public:
|
|||||||
// STL compatibility
|
// STL compatibility
|
||||||
inline bool empty() const { return isEmpty(); }
|
inline bool empty() const { return isEmpty(); }
|
||||||
|
|
||||||
QPair<iterator, iterator> equal_range(const Key &akey)
|
std::pair<iterator, iterator> equal_range(const Key &akey)
|
||||||
{
|
{
|
||||||
const auto copy = d.isShared() ? *this : QMultiMap(); // keep `key` alive across the detach
|
const auto copy = d.isShared() ? *this : QMultiMap(); // keep `key` alive across the detach
|
||||||
detach();
|
detach();
|
||||||
@ -1500,7 +1500,7 @@ public:
|
|||||||
return {iterator(result.first), iterator(result.second)};
|
return {iterator(result.first), iterator(result.second)};
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<const_iterator, const_iterator> equal_range(const Key &akey) const
|
std::pair<const_iterator, const_iterator> equal_range(const Key &akey) const
|
||||||
{
|
{
|
||||||
if (!d)
|
if (!d)
|
||||||
return {};
|
return {};
|
||||||
|
@ -818,14 +818,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <class Key, class T> QPair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key, T>::equal_range(const Key &key)
|
\fn template <class Key, class T> std::pair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key, T>::equal_range(const Key &key)
|
||||||
|
|
||||||
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
|
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
|
||||||
are stored under \a key.
|
are stored under \a key.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <class Key, class T> QPair<typename QMap<Key, T>::const_iterator, typename QMap<Key, T>::const_iterator> QMap<Key, T>::equal_range(const Key &key) const
|
\fn template <class Key, class T> std::pair<typename QMap<Key, T>::const_iterator, typename QMap<Key, T>::const_iterator> QMap<Key, T>::equal_range(const Key &key) const
|
||||||
\overload
|
\overload
|
||||||
\since 5.6
|
\since 5.6
|
||||||
*/
|
*/
|
||||||
|
@ -934,14 +934,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <class Key, class T> QPair<typename QMultiMap<Key, T>::iterator, typename QMultiMap<Key, T>::iterator> QMultiMap<Key, T>::equal_range(const Key &key)
|
\fn template <class Key, class T> std::pair<typename QMultiMap<Key, T>::iterator, typename QMultiMap<Key, T>::iterator> QMultiMap<Key, T>::equal_range(const Key &key)
|
||||||
|
|
||||||
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
|
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
|
||||||
are stored under \a key.
|
are stored under \a key.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <class Key, class T> QPair<typename QMultiMap<Key, T>::const_iterator, typename QMultiMap<Key, T>::const_iterator> QMultiMap<Key, T>::equal_range(const Key &key) const
|
\fn template <class Key, class T> std::pair<typename QMultiMap<Key, T>::const_iterator, typename QMultiMap<Key, T>::const_iterator> QMultiMap<Key, T>::equal_range(const Key &key) const
|
||||||
\overload
|
\overload
|
||||||
\since 5.6
|
\since 5.6
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user