diff options
Diffstat (limited to 'src/maps/hashmap.tmpl')
| -rw-r--r-- | src/maps/hashmap.tmpl | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/maps/hashmap.tmpl b/src/maps/hashmap.tmpl index 682c395..e9da338 100644 --- a/src/maps/hashmap.tmpl +++ b/src/maps/hashmap.tmpl @@ -2,38 +2,38 @@ template<class obj_type> obj_type hashmap<obj_type>::get_set_elem(obj_type t_obj, string s_key) { - typename hashmap<obj_type>::iterator iter = this->find(s_key); - + typename hashmap<obj_type>::iterator iter = this->find(s_key); + if ( iter == this->end() ) { set_elem(t_obj, s_key); return obj_type(); } - obj_type t_ret = iter->second; + obj_type t_ret = iter->second; iter->second = t_obj; return t_ret; -} +} template<class obj_type> void hashmap<obj_type>::set_elem(obj_type t_obj, string s_key) { (*this)[s_key] = t_obj; -} +} template<class obj_type> obj_type hashmap<obj_type>::get_elem(string s_key) { - typename hashmap<obj_type>::iterator iter = this->find(s_key); + typename hashmap<obj_type>::iterator iter = this->find(s_key); - if ( iter != this->end() ) - return iter->second; + if ( iter != this->end() ) + return iter->second; - return obj_type(); -} + return obj_type(); +} template<class obj_type> vector<string>* @@ -41,19 +41,19 @@ hashmap<obj_type>::get_key_vector() { vector<string>* p_vec = new vector<string>; typename hashmap<obj_type>::iterator iter; - + for ( iter = this->begin(); iter != this->end(); ++iter ) p_vec->push_back(iter->first); - return p_vec; -} + return p_vec; +} template<class obj_type> bool hashmap<obj_type>::exists(string s_key) { - return this->find(s_key) != this->end(); -} + return this->find(s_key) != this->end(); +} template<class obj_type> void |
