From 7b7c3355f2a2bd7bb7fdbe8ad343b8524901af71 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 28 Jan 2022 00:54:32 +0100 Subject: [PATCH] QFlatMap: add full is_transparent support [1/3]: split functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Qt CI Bot Reviewed-by: Fabian Kosmale Reviewed-by: Jörg Bornemann --- src/corelib/tools/qflatmap_p.h | 16 ++++++++++++++-- 1 file 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 {