summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qmap.qdoc
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-16 20:52:48 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-12-02 10:35:14 +0100
commite12e2b43b7e6b42d17556eb8ed392c31589a0b4a (patch)
tree1575582d6d78bd66914c2499daba0df8c997ed48 /src/corelib/tools/qmap.qdoc
parent9341f2e3d0a877b50ba851ff22b0d6ce192faf84 (diff)
Associative containers: add erase_if
Use a trick similar to the one we use for their ranged constructors: support predicates that either take a container's iterator, or that take a std::pair (for STL compatibility). [ChangeLog][QtCore][QMap] Added removeIf() and erase_if(). [ChangeLog][QtCore][QMultiMap] Added removeIf() and erase_if(). [ChangeLog][QtCore][QHash] Added removeIf() and erase_if(). [ChangeLog][QtCore][QMultiHash] Added removeIf() and erase_if(). Change-Id: Ie40aadf6217d7a4126a626c390d530812ebcf020 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qmap.qdoc')
-rw-r--r--src/corelib/tools/qmap.qdoc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/corelib/tools/qmap.qdoc b/src/corelib/tools/qmap.qdoc
index ace09e7391..3fec85e5b2 100644
--- a/src/corelib/tools/qmap.qdoc
+++ b/src/corelib/tools/qmap.qdoc
@@ -334,6 +334,21 @@
\sa clear(), take()
*/
+/*! \fn template <class Key, class T> template <typename Predicate> size_type QMap<Key, T>::removeIf(Predicate pred)
+ \since 6.1
+
+ Removes all elements for which the predicate \a pred returns true
+ from the map.
+
+ The function supports predicates which take either an argument of
+ type \c{QMap<Key, T>::iterator}, or an argument of type
+ \c{std::pair<const Key &, T &>}.
+
+ Returns the number of elements removed, if any.
+
+ \sa clear(), take()
+*/
+
/*! \fn template <class Key, class T> T QMap<Key, T>::take(const Key &key)
Removes the item with the key \a key from the map and returns
@@ -1372,3 +1387,17 @@
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
+
+/*! \fn template <typename Key, typename T, typename Predicate> qsizetype erase_if(QMap<Key, T> &map, Predicate pred)
+ \relates QMap
+ \since 6.1
+
+ Removes all elements for which the predicate \a pred returns true
+ from the map \a map.
+
+ The function supports predicates which take either an argument of
+ type \c{QMap<Key, T>::iterator}, or an argument of type
+ \c{std::pair<const Key &, T &>}.
+
+ Returns the number of elements removed, if any.
+*/