diff options
Diffstat (limited to 'src/maps')
| -rw-r--r-- | src/maps/hmap.h | 6 | ||||
| -rw-r--r-- | src/maps/hmap.tmpl | 11 | ||||
| -rw-r--r-- | src/maps/mtools.h | 6 | ||||
| -rw-r--r-- | src/maps/mtools.tmpl | 5 | ||||
| -rw-r--r-- | src/maps/smap.h | 1 | ||||
| -rw-r--r-- | src/maps/smap.tmpl | 8 |
6 files changed, 12 insertions, 25 deletions
diff --git a/src/maps/hmap.h b/src/maps/hmap.h index 38ea2e4..a0824ec 100644 --- a/src/maps/hmap.h +++ b/src/maps/hmap.h @@ -9,6 +9,11 @@ using namespace std; +// void add_elem( obj_type x, key_type k ) --> Insert x +// void del_elem( key_type k ) --> Remove x +// obj_type get_elem( key_type k ) --> Return item that matches x +// void make_empty( ) --> Remove all items + template <class obj_type, class key_type> class hmap { @@ -72,7 +77,6 @@ public: virtual void make_empty( ); virtual void make_empty( void (*func)(key_type) ); virtual void del_elem ( const key_type &k ); - virtual void rename_key ( const key_type &k1, const key_type &k2 ); virtual obj_type set_elem ( const obj_type &x, const key_type &k ); virtual void run_func( void (*func)(obj_type) ); diff --git a/src/maps/hmap.tmpl b/src/maps/hmap.tmpl index dcd0426..10facac 100644 --- a/src/maps/hmap.tmpl +++ b/src/maps/hmap.tmpl @@ -104,17 +104,6 @@ void hmap<obj_type, key_type>::del_elem( const key_type & k ) array[ i_current_pos ].info = DELETED; } -// Remove item x from the hash table. -template <class obj_type, class key_type> -void hmap<obj_type, key_type>::rename_key( const key_type & k1, const key_type & k2 ) -{ - int i_current_pos = find_pos( k1 ); - if( is_active( i_current_pos ) ) { - array[ i_current_pos ].info = DELETED; - add_elem( array[ i_current_pos ].element, k2 ); - } -} - // Finds item x and resets its value. template <class obj_type, class key_type> obj_type hmap<obj_type, key_type>::set_elem( const obj_type & x, const key_type & k ) diff --git a/src/maps/mtools.h b/src/maps/mtools.h index 4ee45b8..f32a49e 100644 --- a/src/maps/mtools.h +++ b/src/maps/mtools.h @@ -1,6 +1,7 @@ #ifndef MTOOLS_H #define MTOOLS_H + template <class type_> struct mtools { @@ -8,4 +9,7 @@ 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/smap.h b/src/maps/smap.h index 2096139..e056519 100644 --- a/src/maps/smap.h +++ b/src/maps/smap.h @@ -30,7 +30,6 @@ class smap : public hmap<obj_type, key_type> void add_elem ( const obj_type &x, const key_type &k ); obj_type set_elem ( const obj_type &x, const key_type &k ); void del_elem ( const key_type &k ); - void rename_key ( const key_type &k1, const key_type &k2 ); bool is_avail ( const key_type &k ); obj_type get_elem ( const key_type &k ); obj_type pop_elem ( const key_type &k ); diff --git a/src/maps/smap.tmpl b/src/maps/smap.tmpl index 5ec7d38..3167504 100644 --- a/src/maps/smap.tmpl +++ b/src/maps/smap.tmpl @@ -77,14 +77,6 @@ smap<obj_type, key_type>::del_elem( const key_type & k ) pthread_mutex_unlock( &mut_smap ); } -template <class obj_type, class key_type> void -smap<obj_type, key_type>::rename_key( const key_type & k1, const key_type & k2 ) -{ - pthread_mutex_lock ( &mut_smap ); - hmap<obj_type,key_type>::rename_key( k1, k2 ); - pthread_mutex_unlock( &mut_smap ); -} - template <class obj_type, class key_type> obj_type smap<obj_type, key_type>::get_elem( const key_type &k ) |
