1 #ifndef __ADDITIVEMAP_HH__
2 #define __ADDITIVEMAP_HH__
7 template<
typename K,
typename V,
typename EqualKey = d3::util::equal<K> >
10 typedef std::vector<std::pair<K,V> >
mapType;
26 while (res !=
map.end()) {
27 if (EqualKey () (res->first,key))
44 if (
add (val.first,val.second) )
52 bool add (
const K & key,
const V & value) {
53 typename mapType::iterator it =
find(key);
54 if ( it !=
map.end() ) {
56 it->second = it->second + value ;
59 map.push_back(std::make_pair(key,value));
65 bool remove (
const K & key,
const V & value) {
66 typename mapType::iterator it =
find(key);
67 if ( it !=
map.end() ) {
69 it->second = it->second - value ;
Definition: AdditiveMap.hpp:8
mapType map
Definition: AdditiveMap.hpp:12
int addAll(const AdditiveMap< K, V > &other)
Definition: AdditiveMap.hpp:34
mapType::const_iterator const_iterator
Definition: AdditiveMap.hpp:16
AdditiveMap()
Definition: AdditiveMap.hpp:18
bool remove(const K &key, const V &value)
Definition: AdditiveMap.hpp:65
const_iterator begin() const
Definition: AdditiveMap.hpp:22
std::vector< std::pair< K, V > > mapType
Definition: AdditiveMap.hpp:10
bool add(const K &key, const V &value)
Definition: AdditiveMap.hpp:52
iterator find(const K &key)
Definition: AdditiveMap.hpp:24
const_iterator end() const
Definition: AdditiveMap.hpp:21
mapType::iterator iterator
Definition: AdditiveMap.hpp:17
int addAll(const_iterator begin, const_iterator end)
Definition: AdditiveMap.hpp:40
mapType::value_type value_type
Definition: AdditiveMap.hpp:15