From 4f7b21e9c96e9c537fa2a5f446ac37e77d2a333a Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Fri, 3 Jul 2020 14:30:05 +0200 Subject: [PATCH] [MeL] Overload Properties::size() for item types. Counts number of properties on a given mesh item type. --- MeshLib/Properties.cpp | 8 ++++++++ MeshLib/Properties.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/MeshLib/Properties.cpp b/MeshLib/Properties.cpp index a29145acb07..8d8b5bcfc2b 100644 --- a/MeshLib/Properties.cpp +++ b/MeshLib/Properties.cpp @@ -167,4 +167,12 @@ std::map<std::string, PropertyVectorBase*>::size_type Properties::size() const { return _properties.size(); } + +std::map<std::string, PropertyVectorBase*>::size_type Properties::size( + MeshItemType const mesh_item_type) const +{ + return count_if(begin(), end(), [&](auto const p) { + return p.second->getMeshItemType() == mesh_item_type; + }); +} } // end namespace MeshLib diff --git a/MeshLib/Properties.h b/MeshLib/Properties.h index f6dc79863e5..693af4d9eda 100644 --- a/MeshLib/Properties.h +++ b/MeshLib/Properties.h @@ -155,6 +155,9 @@ public: std::map<std::string, PropertyVectorBase*>::iterator begin(); std::map<std::string, PropertyVectorBase*>::iterator end(); std::map<std::string, PropertyVectorBase*>::size_type size() const; + // Counts properties of given mesh item type. + std::map<std::string, PropertyVectorBase*>::size_type size( + MeshItemType const mesh_item_type) const; private: /// A mapping from property's name to the stored object of any type. -- GitLab