QHash: merge the two equal_range() overloads
They were literally identical (as in, they used exactly the same letters in the exact same order), but changed on whether *this was const or not. So pass *this as a parameter so we can have just one implementation. QMultiHash doesn't need this change because its non-const equal_range() calls the const version after making a copy. Change-Id: I6818d78a57394e37857bfffd17ba06aee2e7db0b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
ba24125cbf
commit
07c8cece05
|
|
@ -1224,22 +1224,23 @@ public:
|
|||
|
||||
std::pair<iterator, iterator> equal_range(const Key &key)
|
||||
{
|
||||
auto first = find(key);
|
||||
auto second = first;
|
||||
if (second != iterator())
|
||||
++second;
|
||||
return {first, second};
|
||||
return equal_range_impl(*this, key);
|
||||
}
|
||||
|
||||
std::pair<const_iterator, const_iterator> equal_range(const Key &key) const noexcept
|
||||
{
|
||||
auto first = find(key);
|
||||
return equal_range_impl(*this, key);
|
||||
}
|
||||
private:
|
||||
template <typename Hash, typename K> static auto equal_range_impl(Hash &self, const K &key)
|
||||
{
|
||||
auto first = self.find(key);
|
||||
auto second = first;
|
||||
if (second != iterator())
|
||||
if (second != decltype(first){})
|
||||
++second;
|
||||
return {first, second};
|
||||
return std::make_pair(first, second);
|
||||
}
|
||||
|
||||
public:
|
||||
typedef iterator Iterator;
|
||||
typedef const_iterator ConstIterator;
|
||||
inline qsizetype count() const noexcept { return d ? qsizetype(d->size) : 0; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue