13 #ifndef __STOUT_MULTIMAP_HPP__ 14 #define __STOUT_MULTIMAP_HPP__ 29 template <
typename K,
typename V>
34 Multimap(std::initializer_list<std::pair<const K, V>>
list);
36 void put(
const K& key,
const V& value);
37 std::list<V>
get(
const K& key)
const;
38 std::set<K>
keys()
const;
39 bool remove(
const K& key);
40 bool remove(
const K& key,
const V& value);
42 bool contains(
const K& key,
const V& value)
const;
46 template <
typename K,
typename V>
52 template <
typename K,
typename V>
55 std::multimap<K, V>::insert(std::pair<K, V>(key, value));
59 template <
typename K,
typename V>
64 std::pair<typename std::multimap<K, V>::const_iterator,
65 typename std::multimap<K, V>::const_iterator> range;
67 range = std::multimap<K, V>::equal_range(key);
69 typename std::multimap<K, V>::const_iterator i;
70 for (i = range.first; i != range.second; ++i) {
71 values.push_back(i->second);
78 template <
typename K,
typename V>
89 template <
typename K,
typename V>
92 return std::multimap<K, V>::erase(key) > 0;
96 template <
typename K,
typename V>
99 std::pair<typename std::multimap<K, V>::iterator,
100 typename std::multimap<K, V>::iterator> range;
102 range = std::multimap<K, V>::equal_range(key);
104 typename std::multimap<K, V>::iterator i;
105 for (i = range.first; i != range.second; ++i) {
106 if (i->second == value) {
107 std::multimap<K, V>::erase(i);
116 template <
typename K,
typename V>
119 return std::multimap<K, V>::count(key) > 0;
123 template <
typename K,
typename V>
126 const std::list<V> values =
get(key);
127 return std::find(values.begin(), values.end(), value) != values.end();
130 #endif // __STOUT_MULTIMAP_HPP__ Definition: type_utils.hpp:619
bool contains(const K &key) const
Definition: multimap.hpp:117
std::set< K > keys() const
Definition: multimap.hpp:79
std::list< V > get(const K &key) const
Definition: multimap.hpp:60
Multimap()
Definition: multimap.hpp:33
Definition: multimap.hpp:30
Try< std::vector< Entry > > list(const std::string &hierarchy, const std::string &cgroup)
void put(const K &key, const V &value)
Definition: multimap.hpp:53
#define foreachkey(KEY, ELEMS)
Definition: foreach.hpp:74
bool remove(const K &key)
Definition: multimap.hpp:90
Try< std::list< std::string > > find(const std::string &directory, const std::string &pattern)
Definition: find.hpp:37