44 #include <QtCore/qiterator.h>
45 #include <QtCore/qlist.h>
46 #include <QtCore/qrefcount.h>
47 #include <QtCore/qpair.h>
48 #include <QtCore/qshareddata.h>
49 #include <QtCore/qshareddata_impl.h>
52 #include <initializer_list>
59 template <
typename AMap>
71 static_assert(std::is_nothrow_destructible_v<Key>,
"Types with throwing destructors are not supported in Qt containers.");
72 static_assert(std::is_nothrow_destructible_v<T>,
"Types with throwing destructors are not supported in Qt containers.");
92 const auto &keyCompare =
source.key_comp();
95 if (!keyCompare(
key,
v.first) && !keyCompare(
v.first,
key)) {
104 std::inserter(
m,
m.end()),
114 return [&
value](
const auto &
v) {
return v.second ==
value; };
119 auto i = std::find_if(
m.cbegin(),
133 const auto extractKey = [](
const auto &
v) {
return v.first; };
137 std::back_inserter(
result),
147 for (
const auto &
v :
m) {
160 const auto extractValue = [](
const auto &
v) {
return v.second; };
164 std::back_inserter(
result),
188 const auto newDataEnd =
result.it;
191 const auto e =
m.end();
205 result.data->m.insert(newDataEnd, *
i);
209 if (
result.it != newDataEnd)
220 template <
class Key,
class T>
223 using Map = std::map<Key, T>;
244 QMap(std::initializer_list<std::pair<Key, T>>
list)
273 return std::move(
d->m);
280 template <
typename AKey = Key,
typename AT = T>
friend
288 return rhs.d ? (lhs.d->m ==
rhs.d->m) : lhs.d->m.empty();
291 template <
typename AKey = Key,
typename AT = T>
friend
294 return !(lhs ==
rhs);
304 bool isEmpty()
const {
return d ?
d->m.empty() :
true; }
316 return d ? !
d.isShared() :
false;
351 template <
typename Predicate>
362 const auto copy =
d.isShared() ? *
this :
QMap();
367 auto i =
d->m.find(
key);
368 if (
i !=
d->m.end()) {
380 auto i =
d->m.find(
key);
381 return i !=
d->m.end();
389 return d->key(
value, defaultKey);
396 const auto i =
d->m.find(
key);
397 if (
i !=
d->m.cend())
404 const auto copy =
d.isShared() ? *
this :
QMap();
406 auto i =
d->m.find(
key);
443 return d->count(
key);
507 #if QT_DEPRECATED_SINCE(6, 0)
578 #if QT_DEPRECATED_SINCE(6, 0)
661 return iterator(
d->m.erase(afirst.i, alast.i));
663 auto result =
d->erase(afirst.i, alast.i);
674 const auto copy =
d.isShared() ? *
this :
QMap();
693 const auto copy =
d.isShared() ? *
this :
QMap();
707 const auto copy =
d.isShared() ? *
this :
QMap();
721 const auto copy =
d.isShared() ? *
this :
QMap();
731 const auto copy =
d.isShared() ? *
this :
QMap();
732 if (!
d ||
d.isShared()) {
750 #ifdef __cpp_lib_node_extract
751 auto copy =
map.d->m;
752 copy.merge(std::move(
d->m));
753 d->m = std::move(copy);
757 auto insertionHint =
d->m.end();
758 auto mapIt =
map.d->m.crbegin();
759 auto end =
map.d->m.crend();
760 for (; mapIt !=
end; ++mapIt)
761 insertionHint =
d->m.insert_or_assign(insertionHint, mapIt->first, mapIt->second);
767 if (!
map.d ||
map.d->m.empty())
770 if (
map.d.isShared()) {
778 #ifdef __cpp_lib_node_extract
779 map.d->m.merge(std::move(
d->m));
780 *
this = std::move(
map);
783 auto insertionHint =
d->m.end();
784 auto mapIt =
map.d->m.crbegin();
785 auto end =
map.d->m.crend();
786 for (; mapIt !=
end; ++mapIt)
787 insertionHint =
d->m.insert_or_assign(insertionHint, std::move(mapIt->first), std::move(mapIt->second));
799 const auto copy =
d.isShared() ? *
this :
QMap();
801 auto result =
d->m.equal_range(akey);
809 auto result =
d->m.equal_range(akey);
817 template <
typename Key,
typename T,
typename Predicate>
827 template <
class Key,
class T>
830 using Map = std::multimap<Key, T>;
860 d->m.insert(
other.d->m.begin(),
870 if (
other.d.isShared()) {
871 d->m.insert(
other.d->m.begin(),
874 #ifdef __cpp_lib_node_extract
875 d->m.merge(std::move(
other.d->m));
877 d->m.insert(std::make_move_iterator(
other.d->m.begin()),
878 std::make_move_iterator(
other.d->m.end()));
914 return std::move(
d->m);
921 template <
typename AKey = Key,
typename AT = T>
friend
929 return rhs.d ? (lhs.d->m ==
rhs.d->m) : lhs.d->m.empty();
932 template <
typename AKey = Key,
typename AT = T>
friend
935 return !(lhs ==
rhs);
945 bool isEmpty()
const {
return d ?
d->m.empty() :
true; }
957 return d ? !
d.isShared() :
false;
1001 const T valueCopy =
value;
1007 const auto &keyCompare =
d->m.key_comp();
1009 auto i =
d->m.find(keyCopy);
1010 const auto e =
d->m.end();
1012 while (
i !=
e && !keyCompare(keyCopy,
i->first)) {
1013 if (
i->second == valueCopy) {
1024 template <
typename Predicate>
1041 auto i =
d->m.find(
key);
1042 if (
i !=
d->m.end()) {
1054 auto i =
d->m.find(
key);
1055 return i !=
d->m.end();
1068 return d->key(
value, defaultKey);
1074 return defaultValue;
1075 const auto i =
d->m.find(
key);
1076 if (
i !=
d->m.cend())
1078 return defaultValue;
1104 std::back_inserter(
result));
1130 return d->count(
key);
1202 #if QT_DEPRECATED_SINCE(6, 0)
1273 #if QT_DEPRECATED_SINCE(6, 0)
1356 return iterator(
d->m.erase(afirst.i, alast.i));
1358 auto result =
d->erase(afirst.i, alast.i);
1459 auto i =
d->m.lower_bound(
key);
1460 return iterator(
d->m.insert(
i, {key, value}));
1467 if (!
d ||
d.isShared()) {
1470 dpos =
std::next(
d->m.cbegin(), posDistance);
1474 return iterator(
d->m.insert(dpos, {key, value}));
1477 #if QT_DEPRECATED_SINCE(6, 0)
1511 auto i =
d->m.find(
key);
1512 if (
i !=
d->m.end())
1527 auto result =
d->m.equal_range(akey);
1535 auto result =
d->m.equal_range(akey);
1541 if (
other.isEmpty())
1546 auto copy =
other.d->m;
1547 #ifdef __cpp_lib_node_extract
1548 copy.merge(std::move(
d->m));
1550 copy.insert(std::make_move_iterator(
d->m.begin()),
1551 std::make_move_iterator(
d->m.end()));
1553 d->m = std::move(copy);
1562 if (
other.d.isShared()) {
1570 #ifdef __cpp_lib_node_extract
1571 other.d->m.merge(std::move(
d->m));
1573 other.d->m.insert(std::make_move_iterator(
d->m.begin()),
1574 std::make_move_iterator(
d->m.end()));
1576 *
this = std::move(
other);
1584 template <
typename Key,
typename T>
1592 template <
typename Key,
typename T>
1598 template <
typename Key,
typename T,
typename Predicate>
small capitals from c petite p scientific i
[1]
const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
template< typename Predicate > qsizetype erase_if(QByteArray &ba, Predicate pred)
QPair< QVariant, QVariant > value_type
const_iterator operator++(int)
friend bool operator!=(const const_iterator &lhs, const const_iterator &rhs)
const_iterator & operator--()
const T & operator*() const
friend bool operator==(const const_iterator &lhs, const const_iterator &rhs)
const T * operator->() const
Q_IMPLICIT const_iterator(const iterator &o)
const_iterator operator--(int)
std::bidirectional_iterator_tag iterator_category
const_iterator & operator++()
friend bool operator==(const iterator &lhs, const iterator &rhs)
std::bidirectional_iterator_tag iterator_category
friend bool operator!=(const iterator &lhs, const iterator &rhs)
key_iterator(const_iterator o)
key_iterator & operator++()
const_iterator::iterator_category iterator_category
key_iterator & operator--()
const_iterator base() const
key_iterator operator--(int)
const Key * operator->() const
key_iterator operator++(int)
bool operator==(key_iterator o) const
const_iterator::difference_type difference_type
const Key & operator*() const
bool operator!=(key_iterator o) const
typename Map::iterator iterator
EraseResult erase(const_iterator first, const_iterator last) const
Key key(const T &value, const Key &defaultKey) const
QList< Key > keys() const
typename Map::size_type size_type
size_type count(const Key &key) const
QList< Key > keys(const T &value) const
typename Map::const_iterator const_iterator
typename Map::value_type value_type
size_type copyIfNotEquivalentTo(const Map &source, const Key &key)
QList< T > values() const
static auto valueIsEqualTo(const T &value)
typename Map::key_type Key
QMapData(const Map &other)
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
QList< T > values() const
const_iterator end() const
iterator erase(const_iterator it)
key_value_iterator keyValueEnd()
QList< Key > keys() const
bool contains(const Key &key) const
size_type count(const Key &key) const
QList< Key > keys(const T &value) const
iterator insert(const_iterator pos, const Key &key, const T &value)
const_iterator cend() const
QKeyValueIterator< const Key &, T &, iterator > key_value_iterator
size_type remove(const Key &key)
const Key & lastKey() const
const_key_value_iterator constKeyValueEnd() const
const_iterator cbegin() const
friend QTypeTraits::compare_eq_result_container< QMap, AKey, AT > operator!=(const QMap &lhs, const QMap &rhs)
const_iterator lowerBound(const Key &key) const
const_iterator constFind(const Key &key) const
bool isSharedWith(const QMap< Key, T > &other) const noexcept
QPair< const_iterator, const_iterator > equal_range(const Key &akey) const
QMap(std::initializer_list< std::pair< Key, T >> list)
const_key_value_iterator constKeyValueBegin() const
iterator find(const Key &key)
void insert(const QMap< Key, T > &map)
iterator lowerBound(const Key &key)
const_iterator ConstIterator
std::map< Key, T > toStdMap() const &
T operator[](const Key &key) const
const_key_value_iterator keyValueEnd() const
QMap(std::map< Key, T > &&other)
QPair< iterator, iterator > equal_range(const Key &akey)
iterator upperBound(const Key &key)
iterator erase(const_iterator afirst, const_iterator alast)
std::map< Key, T > toStdMap() &&
const_iterator constBegin() const
const_iterator begin() const
friend QTypeTraits::compare_eq_result_container< QMap, AKey, AT > operator==(const QMap &lhs, const QMap &rhs)
size_type removeIf(Predicate pred)
key_iterator keyBegin() const
const Key & firstKey() const
const_key_value_iterator keyValueBegin() const
key_value_iterator keyValueBegin()
void insert(QMap< Key, T > &&map)
bool isDetached() const noexcept
QMap(const std::map< Key, T > &other)
T & operator[](const Key &key)
Key key(const T &value, const Key &defaultKey=Key()) const
const_iterator constEnd() const
const_iterator upperBound(const Key &key) const
key_iterator keyEnd() const
QKeyValueIterator< const Key &, const T &, const_iterator > const_key_value_iterator
const_iterator find(const Key &key) const
void swap(QMap< Key, T > &other) noexcept
const T & operator*() const
friend bool operator!=(const const_iterator &lhs, const const_iterator &rhs)
Q_IMPLICIT const_iterator(const iterator &o)
const_iterator & operator++()
friend bool operator==(const const_iterator &lhs, const const_iterator &rhs)
const_iterator & operator--()
const_iterator operator--(int)
const_iterator operator++(int)
const T * operator->() const
std::bidirectional_iterator_tag iterator_category
friend bool operator==(const iterator &lhs, const iterator &rhs)
friend bool operator!=(const iterator &lhs, const iterator &rhs)
std::bidirectional_iterator_tag iterator_category
bool operator==(key_iterator o) const
const_iterator::difference_type difference_type
const_iterator base() const
key_iterator(const_iterator o)
key_iterator operator++(int)
const_iterator::iterator_category iterator_category
const Key & operator*() const
key_iterator & operator++()
bool operator!=(key_iterator o) const
key_iterator operator--(int)
const Key * operator->() const
key_iterator & operator--()
const Key & lastKey() const
size_type count(const Key &key) const
const_iterator find(const Key &key, const T &value) const
const Key & firstKey() const
iterator lowerBound(const Key &key)
size_type removeIf(Predicate pred)
iterator replace(const Key &key, const T &value)
const_key_value_iterator constKeyValueEnd() const
QList< Key > uniqueKeys() const
QMultiMap(std::multimap< Key, T > &&other)
QMultiMap & unite(const QMultiMap &other)
QMultiMap(const QMap< Key, T > &other)
QPair< const_iterator, const_iterator > equal_range(const Key &akey) const
const_iterator constFind(const Key &key) const
const_key_value_iterator keyValueBegin() const
QMultiMap(QMap< Key, T > &&other)
QList< Key > keys(const T &value) const
const_iterator constEnd() const
bool contains(const Key &key) const
key_value_iterator keyValueEnd()
bool isSharedWith(const QMultiMap< Key, T > &other) const noexcept
const_key_value_iterator constKeyValueBegin() const
QList< Key > keys() const
std::multimap< Key, T > toStdMultiMap() &&
const_iterator constFind(const Key &key, const T &value) const
key_iterator keyBegin() const
const_iterator find(const Key &key) const
size_type count(const Key &key, const T &value) const
bool contains(const Key &key, const T &value) const
QKeyValueIterator< const Key &, const T &, const_iterator > const_key_value_iterator
const_iterator end() const
friend QTypeTraits::compare_eq_result_container< QMultiMap, AKey, AT > operator!=(const QMultiMap &lhs, const QMultiMap &rhs)
const_iterator upperBound(const Key &key) const
QMultiMap(std::initializer_list< std::pair< Key, T >> list)
QMultiMap(const std::multimap< Key, T > &other)
const_iterator ConstIterator
size_type remove(const Key &key, const T &value)
key_iterator keyEnd() const
friend QTypeTraits::compare_eq_result_container< QMultiMap, AKey, AT > operator==(const QMultiMap &lhs, const QMultiMap &rhs)
iterator find(const Key &key)
iterator insert(const Key &key, const T &value)
iterator erase(const_iterator it)
const_iterator begin() const
const_iterator constBegin() const
size_type remove(const Key &key)
const_iterator cbegin() const
iterator insert(const_iterator pos, const Key &key, const T &value)
std::multimap< Key, T > toStdMultiMap() const &
QList< T > values() const
std::multimap< Key, T > toStdMap() const
T value(const Key &key, const T &defaultValue=T()) const
iterator upperBound(const Key &key)
void swap(QMultiMap< Key, T > &other) noexcept
QList< T > values(const Key &key) const
QKeyValueIterator< const Key &, T &, iterator > key_value_iterator
iterator erase(const_iterator afirst, const_iterator alast)
key_value_iterator keyValueBegin()
iterator find(const Key &key, const T &value)
const_key_value_iterator keyValueEnd() const
bool isDetached() const noexcept
Key key(const T &value, const Key &defaultKey=Key()) const
const_iterator lowerBound(const Key &key) const
QPair< iterator, iterator > equal_range(const Key &akey)
const_iterator cend() const
The QSharedData class is a base class for shared data objects. \reentrant.
QMap< QString, QString > map
[6]
QMultiMap< int, QWidget * > multimap
[28]
auto it unsigned count const
Generic::PredicateMatcher< T > Predicate(std::function< bool(T const &)> const &predicate, std::string const &description="")
typename C::const_iterator const_iterator
typename C::key_type key_type
typename C::mapped_type mapped_type
typename C::iterator iterator
std::enable_if_t< std::conjunction_v< QTypeTraits::has_operator_equal_container< Container, T >... >, bool > compare_eq_result_container
auto associative_erase_if(Container &c, Predicate &pred)
int distance(TestIterator &a, TestIterator &b)
#define Q_DECL_DEPRECATED_X(text)
std::pair< T1, T2 > QPair
EGLOutputLayerEXT EGLint EGLAttrib value
#define QT_DEPRECATED_VERSION_X_6_0(text)
#define Q_DECLARE_ASSOCIATIVE_ITERATOR(C)
#define Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(C)
QMultiMap< Key, T > operator+=(QMultiMap< Key, T > &lhs, const QMultiMap< Key, T > &rhs)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei GLsizei GLchar * source
GLuint GLenum GLenum transform