proj home

Files   Classes   Functions   Hierarchy  

hashtable2< T, HFN > Class Template Reference

Hash table with memory management. More...

#include <hashtable2.h>

Inheritance diagram for hashtable2< T, HFN >:
Collaboration diagram for hashtable2< T, HFN >:

List of all members.

Public Member Functions

 hashtable2 (uintc bucketsize_, HFN fn_)
 Pre allocate the bucket size.
 ~hashtable2 ()
 Memory cleanup.
void insert (T const &val)
 Insert a value into the hash table.
template<typename K >
void insert (K const *ibeg, K const *iend)
 Insert a container into the hash table.


Detailed Description

template<typename T, typename HFN>
class hashtable2< T, HFN >

Hash table with memory management.

Example
  hashfunction01 hfn(8);
  hashtable2<int,hashfunction01> h(60,hfn);
  h.insert(&v[0],&v[0]+vsz);

  ...
  if (h.contains(5)) ...

Definition at line 24 of file hashtable2.h.


Constructor & Destructor Documentation

template<typename T, typename HFN>
hashtable2< T, HFN >::hashtable2 ( uintc  bucketsize_,
HFN  fn_ 
) [inline]

Pre allocate the bucket size.

Definition at line 35 of file hashtable2.h.

00039     : hashtable<T,HFN>(bucketsize_,fn_) {}

template<typename T , typename HFN >
hashtable2< T, HFN >::~hashtable2 (  )  [inline]

Memory cleanup.

Definition at line 57 of file hashtable2.h.

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 }


Member Function Documentation

template<typename T , typename HFN >
template<typename K >
void hashtable2< T, HFN >::insert ( K const *  ibeg,
K const *  iend 
) [inline]

Insert a container into the hash table.

Definition at line 79 of file hashtable2.h.

References hashtable2< T, HFN >::insert().

00080 {
00081   T const * i=ibeg;
00082   for ( ; i!=iend; ++i )
00083     insert(*i);
00084 }

template<typename T , typename HFN >
void hashtable2< T, HFN >::insert ( T const &  val  )  [inline]

Insert a value into the hash table.

Definition at line 69 of file hashtable2.h.

Referenced by hashtable2< T, HFN >::insert(), and hashtabletest::test04unit().

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 }


The documentation for this class was generated from the following file:

Generated on Fri Mar 4 00:50:02 2011 for Chelton Evans Source by  doxygen 1.5.8