proj home

Files   Classes   Functions   Hierarchy  

hashtable2.h

Go to the documentation of this file.
00001 #ifndef HASHTABLE2_H
00002 #define HASHTABLE2_H
00003 
00004 #include <vector>
00005 using namespace std;
00006 
00007 #include <bucketlink.h>
00008 #include <typedefs.h>
00009 
00023 template< typename T, typename HFN >
00024 class hashtable2 : public hashtable<T,HFN>
00025 {  
00026 
00028   vector< bucketlink<T> * > bucketlinks;
00030   vector< T * > data;
00031 public:
00032 
00034   hashtable2
00035   (
00036     uintc bucketsize_,
00037     HFN fn_
00038   ) 
00039     : hashtable<T,HFN>(bucketsize_,fn_) {}
00040 
00042   ~hashtable2();
00043 
00045   void insert( T const & val );
00046 
00048   template < typename K >
00049   void insert( K const * ibeg, K const * iend);
00050 
00051 };
00052 
00053 //---------------------------------------------------------
00054 // Implementation
00055 
00056 template< typename T, typename HFN >
00057 hashtable2<T,HFN>::~hashtable2()
00058 {
00059   uintc imax=bucketlinks.size();
00060   for (uint i=0; i<imax; ++i)
00061   {
00062     delete[] data[i];
00063     delete[] bucketlinks[i];
00064   }
00065   bucketlinks.clear();
00066 }
00067 
00068 template< typename T, typename HFN >
00069 void hashtable2<T,HFN>::insert( T const & val )
00070 {
00071   uintc sz=data.size();
00072   data.push_back( new T(val) );
00073   bucketlinks.push_back( new bucketlink<T>( data[sz] ) );
00074   hashtable<T,HFN>::insert( bucketlinks[sz] ); 
00075 }
00076 
00077 template< typename T, typename HFN >
00078 template< typename K >
00079 void hashtable2<T,HFN>::insert( K const * ibeg, K const * iend )
00080 {
00081   T const * i=ibeg;
00082   for ( ; i!=iend; ++i )
00083     insert(*i);
00084 }
00085 
00086 
00087 #endif
00088 

Generated on Fri Mar 4 00:49:26 2011 for Chelton Evans Source by  doxygen 1.5.8