3 Copyright (C) 2003-2009 Kevin Thornton, krthornt[]@[]uci.edu
5 Remove the brackets to email me.
7 This file is part of libsequence.
9 libsequence is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 libsequence is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 long with libsequence. If not, see <http://www.gnu.org/licenses/>.
25 #ifndef __COUNTING_OPERATORS_TCC__
26 #define __COUNTING_OPERATORS_TCC__
27 #include <Sequence/CountingOperators.hpp>
31 template<typename key, typename value>
32 std::vector<std::pair<key,value> >
33 operator+(const std::vector<std::pair<key,value> > &lhs,
34 const std::vector<std::pair<key,value> > &rhs)
36 typedef std::vector<std::pair<key,value> > rt; //return type
38 for(typename rt::const_iterator itr = rhs.begin();
42 typename rt::iterator i = std::find_if(rv.begin(),
44 std::bind2nd(first_is_equal<key,value>(),*itr));
47 i->second += itr->second;
57 template<typename key, typename value>
58 std::vector<std::pair<key,value> >
59 operator+=( std::vector<std::pair<key,value> > &lhs,
60 const std::vector<std::pair<key,value> > &rhs)
65 template< typename key, typename value,typename comparison>
66 std::map<key,value,comparison> operator+(const std::map<key,value,comparison> &lhs,
67 const std::map<key,value,comparison> &rhs)
69 typedef std::map<key,value,comparison> rt;
71 for(typename rt::const_iterator itr = rhs.begin() ;
75 typename rt::iterator i = rv.find(itr->first);
78 i->second += itr->second;
82 rv[itr->first] = itr->second;
88 template< typename key, typename value,typename comparison>
89 std::map<key,value,comparison> operator+=( std::map<key,value,comparison> &lhs,
90 const std::map<key,value,comparison> &rhs)