From e6dbc2041e5bedf0b4aa27eb08346344aabb393b Mon Sep 17 00:00:00 2001 From: Kate Unger Date: Sun, 9 Jul 2023 21:51:24 -0700 Subject: [PATCH 1/3] fix container.h --- lib/utils/include/utils/containers.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/utils/include/utils/containers.h b/lib/utils/include/utils/containers.h index 25b637b769..48b68aaee9 100644 --- a/lib/utils/include/utils/containers.h +++ b/lib/utils/include/utils/containers.h @@ -526,9 +526,9 @@ std::vector sorted_by(std::unordered_set const &s, F const &f) { template void inplace_sorted_by(std::vector &v, F const &f) { - struct { - bool operator()(T const &lhs, T const &rhs) { return f(lhs, rhs); } - } custom_comparator; + auto custom_comparator = [&](T const &lhs, T const &rhs) -> bool { + return f(lhs, rhs); + }; std::sort(v.begin(), v.end(), custom_comparator); } From dd6864721ea9a7a50c344c3f2d56bef18c06498a Mon Sep 17 00:00:00 2001 From: Kate Unger Date: Sun, 9 Jul 2023 21:57:25 -0700 Subject: [PATCH 2/3] format containers.h --- lib/utils/include/utils/containers.h | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/utils/include/utils/containers.h b/lib/utils/include/utils/containers.h index 48b68aaee9..a38e1af88a 100644 --- a/lib/utils/include/utils/containers.h +++ b/lib/utils/include/utils/containers.h @@ -135,7 +135,7 @@ template ()(std::declval()))> std::unordered_map map_keys(std::unordered_map const &m, - F const &f) { + F const &f) { std::unordered_map result; for (auto const &kv : f) { result.insert({f(kv.first), kv.second}); @@ -147,8 +147,7 @@ template ()(std::declval()))> -bidict map_keys(bidict const &m, - F const &f) { +bidict map_keys(bidict const &m, F const &f) { bidict result; for (auto const &kv : f) { result.equate(f(kv.first), kv.second); @@ -185,8 +184,7 @@ template ()(std::declval()))> -bidict map_values(bidict const &m, - F const &f) { +bidict map_values(bidict const &m, F const &f) { bidict result; for (auto const &kv : m) { result.equate({kv.first, f(kv.second)}); @@ -194,7 +192,6 @@ bidict map_values(bidict const &m, return result; } - template std::unordered_map filter_values(std::unordered_map const &m, F const &f) { @@ -226,13 +223,8 @@ std::vector values(C const &c) { } template -std::unordered_set< - std::pair< - typename C::key_type, - typename C::value_type - > -> -items(C const &c) { +std::unordered_set> + items(C const &c) { return {c.begin(), c.end()}; } @@ -529,7 +521,7 @@ void inplace_sorted_by(std::vector &v, F const &f) { auto custom_comparator = [&](T const &lhs, T const &rhs) -> bool { return f(lhs, rhs); }; - + std::sort(v.begin(), v.end(), custom_comparator); } From 38a6d3642a934664511a5626a158ade00abb9fcc Mon Sep 17 00:00:00 2001 From: Kate Unger <32380357+KateUnger@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:34:31 -0700 Subject: [PATCH 3/3] Update containers.h --- lib/utils/include/utils/containers.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/utils/include/utils/containers.h b/lib/utils/include/utils/containers.h index fbd356cacb..fd00745a4b 100644 --- a/lib/utils/include/utils/containers.h +++ b/lib/utils/include/utils/containers.h @@ -518,7 +518,6 @@ std::vector sorted_by(std::unordered_set const &s, F const &f) { template void inplace_sorted_by(std::vector &v, F const &f) { - struct { auto custom_comparator = [&](T const &lhs, T const &rhs) -> bool { return f(lhs, rhs); };