From ef37a748ff59400bc5accd5d32adad7b2fd62893 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 17 Nov 2018 20:55:17 -0600 Subject: [PATCH] Added grep method for containers (returns a new copy of the container that returns true for the lambda function). --- src/GUI/misc_ui.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/GUI/misc_ui.hpp b/src/GUI/misc_ui.hpp index ec24a57d1..251ca84a0 100644 --- a/src/GUI/misc_ui.hpp +++ b/src/GUI/misc_ui.hpp @@ -177,6 +177,14 @@ public: } }; +/// Quick implementation of grep to filter containers based on some lambda function. +template +T grep(const T& container, G lambda_func) { + T result; + std::copy_if(container.cbegin(), container.cend(), std::back_inserter(result), lambda_func); + return result; +} + }} // namespace Slic3r::GUI #endif // MISC_UI_HPP