diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-01-28 00:54:32 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-01-29 02:40:12 +0100 |
commit | 7b7c3355f2a2bd7bb7fdbe8ad343b8524901af71 (patch) | |
tree | acbe5aab589b682b67b65b103cf2b89ac5a7aee9 | |
parent | f08f28548ae04f89bd7fd24673c1369c96786e3d (diff) |
QFlatMap: add full is_transparent support [1/3]: split functions
Extract Methods do_foo(iterator) from their respective foo(Key)
methods.
This is done in order to separate the common code from the code that
will differ in the is_transparent overloads.
Leave the function bodies where they previously appeared, for easier
reviewing.
Pick-to: 6.3
Change-Id: I49f41f9121a047df696f39daeaa0a9da6a16dddb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | src/corelib/tools/qflatmap_p.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h index d9bcf08c9d..5c2aadb4d3 100644 --- a/src/corelib/tools/qflatmap_p.h +++ b/src/corelib/tools/qflatmap_p.h @@ -607,13 +607,19 @@ public: bool remove(const Key &key) { - auto it = binary_find(key); + return do_remove(binary_find(key)); + } + +private: + bool do_remove(iterator it) + { if (it != end()) { erase(it); return true; } return false; } +public: iterator erase(iterator it) { @@ -623,7 +629,12 @@ public: T take(const Key &key) { - auto it = binary_find(key); + return do_take(binary_find(key)); + } + +private: + T do_take(iterator it) + { if (it != end()) { T result = std::move(it.value()); erase(it); @@ -631,6 +642,7 @@ public: } return {}; } +public: bool contains(const Key &key) const { |