/tags/rel-1.3.35/Examples/python/std_map/example.h
# · C++ Header · 17 lines · 11 code · 5 blank · 1 comment · 2 complexity · a06d443aa0e48a59d85b6d321b1d56eb MD5 · raw file
- /* File : example.h */
- #include <map>
- #include <string>
- template<class Key, class Value>
- std::map<Key,Value> half_map(const std::map<Key,Value>& v) {
- typedef typename std::map<Key,Value>::const_iterator iter;
- std::map<Key,Value> w;
- for (iter i = v.begin(); i != v.end(); ++i) {
- w[i->first] = (i->second)/2;
- }
- return w;
- }