diff --git a/Foundation/include/Poco/HashMap.h b/Foundation/include/Poco/HashMap.h index 3684c211c2..65cd154430 100644 --- a/Foundation/include/Poco/HashMap.h +++ b/Foundation/include/Poco/HashMap.h @@ -180,6 +180,12 @@ class HashMap return _table.find(value); } + std::size_t count(const KeyType& key) const + { + ValueType value(key); + return _table.find(value) != _table.end() ? 1 : 0; + } + std::pair insert(const PairType& pair) { ValueType value(pair.first, pair.second); diff --git a/Foundation/testsuite/src/HashMapTest.cpp b/Foundation/testsuite/src/HashMapTest.cpp index b1a675bfe8..815cf9e8f1 100644 --- a/Foundation/testsuite/src/HashMapTest.cpp +++ b/Foundation/testsuite/src/HashMapTest.cpp @@ -70,6 +70,7 @@ void HashMapTest::testInsert() assert (it != hm.end()); assert (it->first == i); assert (it->second == i*2); + assert (hm.count(i) == 1); assert (hm.size() == i + 1); }