diff options
Diffstat (limited to 'src/maps')
| -rw-r--r-- | src/maps/CVS/Entries | 20 | ||||
| -rw-r--r-- | src/maps/hash.cpp | 18 | ||||
| -rw-r--r-- | src/maps/hash.h | 6 | ||||
| -rw-r--r-- | src/maps/hashmap.h | 14 | ||||
| -rw-r--r-- | src/maps/hashmap.tmpl | 30 | ||||
| -rw-r--r-- | src/maps/mtools.h | 2 | ||||
| -rw-r--r-- | src/maps/mtools.tmpl | 5 | ||||
| -rw-r--r-- | src/maps/nhashmap.h | 2 | ||||
| -rw-r--r-- | src/maps/nhashmap.tmpl | 8 | ||||
| -rw-r--r-- | src/maps/shashmap.h | 33 | ||||
| -rw-r--r-- | src/maps/shashmap.tmpl | 28 |
11 files changed, 83 insertions, 83 deletions
diff --git a/src/maps/CVS/Entries b/src/maps/CVS/Entries index 6033e5b..f7c7407 100644 --- a/src/maps/CVS/Entries +++ b/src/maps/CVS/Entries @@ -1,11 +1,11 @@ -/hash.cpp/1.2/Mon Feb 21 01:55:49 2005// -/hash.h/1.2/Mon Feb 21 01:55:49 2005// -/hashmap.h/1.8/Mon Feb 21 01:55:49 2005// -/hashmap.tmpl/1.4/Mon Feb 21 01:55:49 2005// -/mtools.h/1.7/Mon Feb 21 01:55:49 2005// -/mtools.tmpl/1.6/Mon Feb 21 01:55:49 2005// -/nhashmap.h/1.2/Mon Feb 21 01:55:49 2005// -/nhashmap.tmpl/1.2/Mon Feb 21 01:55:49 2005// -/shashmap.h/1.5/Mon Feb 21 01:55:49 2005// -/shashmap.tmpl/1.4/Mon Feb 21 01:55:49 2005// +/hash.cpp/1.1/Wed Feb 16 21:28:55 2005// +/hash.h/1.1/Wed Feb 16 21:28:55 2005// +/hashmap.h/1.7/Thu Feb 17 00:29:37 2005// +/hashmap.tmpl/1.3/Wed Feb 16 23:16:58 2005// +/mtools.h/1.6/Wed Feb 16 23:16:58 2005// +/mtools.tmpl/1.5/Wed Feb 16 23:16:58 2005// +/nhashmap.h/1.1/Wed Feb 16 22:36:32 2005// +/nhashmap.tmpl/1.1/Wed Feb 16 22:36:32 2005// +/shashmap.h/1.3/Wed Feb 16 23:16:58 2005// +/shashmap.tmpl/1.3/Wed Feb 16 23:16:58 2005// D diff --git a/src/maps/hash.cpp b/src/maps/hash.cpp index b3d80d1..1fb06c4 100644 --- a/src/maps/hash.cpp +++ b/src/maps/hash.cpp @@ -3,24 +3,24 @@ #include "hash.h" -int +int hash::operator()(string s_key) const { - int i_hash = 0; - // cout << key << "%"; + int i_hash = 0; + // cout << key << "%"; - int i_size = s_key.size(); + int i_size = s_key.size(); - for( size_t i = 0; i < i_size; ++i ) - i_hash = ( i_hash << 5 ) ^ s_key.at(i) ^ i_hash; + for( size_t i = 0; i < i_size; ++i ) + i_hash = ( i_hash << 5 ) ^ s_key.at(i) ^ i_hash; - return i_hash; -} + return i_hash; +} bool hashmap_allocator::operator()(string s_key_1, string s_key_2) const { return s_key_1.compare(s_key_2) == 0; -} +} #endif diff --git a/src/maps/hash.h b/src/maps/hash.h index 15ce3fe..a97f091 100644 --- a/src/maps/hash.h +++ b/src/maps/hash.h @@ -1,18 +1,18 @@ #ifndef HASH_H #define HASH_H -#include <string> +#include <string> using namespace std; struct hash { - int operator()(string s_key) const; + int operator()(string s_key) const; }; struct hashmap_allocator { - bool operator()(string s_key_1, string s_key_2) const; + bool operator()(string s_key_1, string s_key_2) const; }; #endif diff --git a/src/maps/hashmap.h b/src/maps/hashmap.h index 3cc2f79..a748bd8 100644 --- a/src/maps/hashmap.h +++ b/src/maps/hashmap.h @@ -11,13 +11,13 @@ using __gnu_cxx::hash_map; template<class obj_type> struct hashmap : public hash_map< string, obj_type, hash, hashmap_allocator> { - virtual inline void set_elem(obj_type t_obj, string s_key); - virtual inline obj_type get_elem(string s_key); - virtual inline obj_type get_set_elem(obj_type t_obj, string s_key); - virtual inline vector<string>* get_key_vector(); - virtual inline bool exists(string s_key); - virtual inline void run_func( void (*func)(obj_type) ); - virtual inline void run_func( void (*func)(obj_type, void*), void* v_arg ); + virtual inline void set_elem(obj_type t_obj, string s_key); + virtual inline obj_type get_elem(string s_key); + virtual inline obj_type get_set_elem(obj_type t_obj, string s_key); + virtual inline vector<string>* get_key_vector(); + virtual inline bool exists(string s_key); + virtual inline void run_func( void (*func)(obj_type) ); + virtual inline void run_func( void (*func)(obj_type, void*), void* v_arg ); }; #include "hashmap.tmpl" 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 diff --git a/src/maps/mtools.h b/src/maps/mtools.h index 4ee45b8..6062191 100644 --- a/src/maps/mtools.h +++ b/src/maps/mtools.h @@ -8,4 +8,4 @@ struct mtools }; #include "mtools.tmpl" -#endif +#endif diff --git a/src/maps/mtools.tmpl b/src/maps/mtools.tmpl index 6917131..dd3f89e 100644 --- a/src/maps/mtools.tmpl +++ b/src/maps/mtools.tmpl @@ -3,10 +3,9 @@ template <class type_> void -mtools<type_>::delete_obj( type_ type_obj ) -{ +mtools<type_>::delete_obj( type_ type_obj ) { if ( type_obj ) - delete type_obj; + delete type_obj; } #endif diff --git a/src/maps/nhashmap.h b/src/maps/nhashmap.h index 4cfb50e..75984b5 100644 --- a/src/maps/nhashmap.h +++ b/src/maps/nhashmap.h @@ -8,7 +8,7 @@ using namespace std; template<class obj_type> struct nhashmap : public shashmap<obj_type> { - inline obj_type get_elem(string s_key); + inline obj_type get_elem(string s_key); }; #include "nhashmap.tmpl" diff --git a/src/maps/nhashmap.tmpl b/src/maps/nhashmap.tmpl index 422ea2f..0cba2fd 100644 --- a/src/maps/nhashmap.tmpl +++ b/src/maps/nhashmap.tmpl @@ -2,10 +2,10 @@ template<class obj_type> obj_type nhashmap<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; + return iter->second; - return NULL; -} + return NULL; +} diff --git a/src/maps/shashmap.h b/src/maps/shashmap.h index e31b55f..a87ed9d 100644 --- a/src/maps/shashmap.h +++ b/src/maps/shashmap.h @@ -5,28 +5,29 @@ #include "hashmap.h" using namespace std; +using __gnu_cxx::hash_map; template<class obj_type> class shashmap : public hashmap<obj_type> { private: - pthread_mutex_t mut_shashmap; + pthread_mutex_t mut_shashmap; public: - explicit shashmap(); - ~shashmap(); - virtual inline void set_elem(obj_type t_obj, string s_key); - virtual inline obj_type get_set_elem(obj_type t_obj, string s_key); - virtual inline void add_elem(obj_type t_obj, string s_key); - virtual inline void add_elem_insecure(obj_type t_obj, string s_key); - virtual inline obj_type get_elem(string s_key); - virtual inline void del_elem(string s_key); - virtual inline void del_elem_insecure(string s_key); - virtual inline void clear(); - virtual inline int size(); - virtual inline bool exists(string s_key); - virtual inline vector<string>* get_key_vector(); - virtual inline void run_func( void (*func)(obj_type) ); - virtual inline void run_func( void (*func)(obj_type, void*), void* v_arg ); + explicit shashmap(); + ~shashmap(); + virtual inline void set_elem(obj_type t_obj, string s_key); + virtual inline obj_type get_set_elem(obj_type t_obj, string s_key); + virtual inline void add_elem(obj_type t_obj, string s_key); + virtual inline void add_elem_insecure(obj_type t_obj, string s_key); + virtual inline obj_type get_elem(string s_key); + virtual inline void del_elem(string s_key); + virtual inline void del_elem_insecure(string s_key); + virtual inline void clear(); + virtual inline int size(); + virtual inline bool exists(string s_key); + virtual inline vector<string>* get_key_vector(); + virtual inline void run_func( void (*func)(obj_type) ); + virtual inline void run_func( void (*func)(obj_type, void*), void* v_arg ); }; #include "shashmap.tmpl" diff --git a/src/maps/shashmap.tmpl b/src/maps/shashmap.tmpl index 7cf4b6b..6a70f61 100644 --- a/src/maps/shashmap.tmpl +++ b/src/maps/shashmap.tmpl @@ -1,13 +1,13 @@ template<class obj_type> shashmap<obj_type>::shashmap() { - pthread_mutex_init( &mut_shashmap, NULL ); + pthread_mutex_init( &mut_shashmap, NULL ); } template<class obj_type> shashmap<obj_type>::~shashmap() { - pthread_mutex_destroy( &mut_shashmap ); + pthread_mutex_destroy( &mut_shashmap ); } template<class obj_type> @@ -17,14 +17,14 @@ shashmap<obj_type>::add_elem(obj_type t_obj, string s_key) pthread_mutex_lock( &mut_shashmap ); (*this)[s_key] = t_obj; pthread_mutex_unlock( &mut_shashmap ); -} +} template<class obj_type> void shashmap<obj_type>::add_elem_insecure(obj_type t_obj, string s_key) { (*this)[s_key] = t_obj; -} +} template<class obj_type> obj_type @@ -34,7 +34,7 @@ shashmap<obj_type>::get_set_elem(obj_type t_obj, string s_key) obj_type t_ret = hashmap<obj_type>::get_set_elem(t_obj, s_key); pthread_mutex_unlock( &mut_shashmap ); return t_ret; -} +} template<class obj_type> void @@ -43,17 +43,17 @@ shashmap<obj_type>::set_elem(obj_type t_obj, string s_key) pthread_mutex_lock( &mut_shashmap ); (*this)[s_key] = t_obj; pthread_mutex_unlock( &mut_shashmap ); -} +} template<class obj_type> obj_type shashmap<obj_type>::get_elem(string s_key) { pthread_mutex_lock( &mut_shashmap ); - obj_type t_ret = hashmap<obj_type>::get_elem(s_key); + obj_type t_ret = hashmap<obj_type>::get_elem(s_key); pthread_mutex_unlock( &mut_shashmap ); return t_ret; -} +} template<class obj_type> void @@ -62,14 +62,14 @@ shashmap<obj_type>::del_elem(string s_key) pthread_mutex_lock( &mut_shashmap ); hashmap<obj_type>::erase(s_key); pthread_mutex_unlock( &mut_shashmap ); -} +} template<class obj_type> void shashmap<obj_type>::del_elem_insecure(string s_key) { hashmap<obj_type>::erase(s_key); -} +} template<class obj_type> vector<string>* @@ -79,7 +79,7 @@ shashmap<obj_type>::get_key_vector() vector<string>* p_vec = hashmap<obj_type>::get_key_vector(); pthread_mutex_unlock( &mut_shashmap ); return p_vec; -} +} template<class obj_type> void @@ -88,7 +88,7 @@ shashmap<obj_type>::clear() pthread_mutex_lock( &mut_shashmap ); hashmap<obj_type>::clear(); pthread_mutex_unlock( &mut_shashmap ); -} +} template<class obj_type> int @@ -98,7 +98,7 @@ shashmap<obj_type>::size() int i_size = hashmap<obj_type>::size(); pthread_mutex_unlock( &mut_shashmap ); return i_size; -} +} template<class obj_type> bool @@ -108,7 +108,7 @@ shashmap<obj_type>::exists(string s_key) bool b_ret = hashmap<obj_type>::exists(s_key); pthread_mutex_unlock( &mut_shashmap ); return b_ret; -} +} template<class obj_type> void |
