From a06f69a71471c6f2c90620da70716564c903a5d7 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 2 Oct 2017 23:29:34 +0200 Subject: [PATCH] [DEV] add count function --- etk/Map.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/etk/Map.hpp b/etk/Map.hpp index 978cd00..ac7185c 100644 --- a/etk/Map.hpp +++ b/etk/Map.hpp @@ -536,6 +536,24 @@ namespace etk { } return position(elementId); } + /** + * @brief Count the number of occurence of a specific element. + * @param[in] _key Name of the element to count iterence + * @return 0 No element was found + * @return 1 One element was found + */ + size_t count(const ETK_MAP_TYPE_KEY& _key) const { + // TODO: search in a dichotomic way. + for (size_t iii=0; iiifirst == _key) { + return 1; + } + } + return 0; + } };