25 #ifndef COMMON_UTILS_COUNTING_MAP_HPP
26 #define COMMON_UTILS_COUNTING_MAP_HPP
28 #include <unordered_map>
42 auto res =
mMap.insert(
typename Map::value_type(key, 1));
46 return res.first->second;
51 auto it =
mMap.find(key);
52 if (it ==
mMap.end()) {
55 if (--it->second == 0) {
67 size_t get(
const Key&
key)
const
70 return it ==
mMap.end() ? 0 : it->second;
78 typedef std::unordered_map<Key, size_t>
Map;
86 #endif // COMMON_UTILS_COUNTING_MAP_HPP
size_t increment(const Key &key)
Definition: counting-map.hpp:40
bool empty() const
Definition: counting-map.hpp:73
Structure used to count elements.
Definition: counting-map.hpp:38
std::string key(const Arg1 &a1, const Args &...args)
Concatenates all parameters into one std::string.
Definition: kvstore-visitor-utils.hpp:60
void clear()
Definition: counting-map.hpp:62
Map mMap
Definition: counting-map.hpp:79
std::unordered_map< Key, size_t > Map
Definition: counting-map.hpp:78
size_t decrement(const Key &key)
Definition: counting-map.hpp:49