19 #ifndef DL_HASHTABLE_HPP 
   20 #define DL_HASHTABLE_HPP 
   22 #include <ndb_global.h> 
   23 #include "ArrayPool.hpp" 
   35 template <
typename P, 
typename T, 
typename U = T>
 
   47   bool setSize(Uint32 noOfElements);
 
   82   T * 
getPtr(Uint32 i) 
const;
 
   88   void remove(
Ptr<T> &, 
const T & key);
 
   94   void remove(Uint32 
i);
 
  121     inline bool isNull()
 const { 
return curr.isNull();}
 
  122     inline void setNull() { curr.setNull(); }
 
  156 template <
typename P, 
typename T, 
typename U>
 
  163   ASSERT_TYPE_HAS_CONSTRUCTOR(T);
 
  169 template <
typename P, 
typename T, 
typename U>
 
  174     delete [] hashValues;
 
  177 template <
typename P, 
typename T, 
typename U>
 
  183   while(i < size) i *= 2;
 
  202   hashValues = 
new Uint32[
i];
 
  203   for(Uint32 j = 0; j<
i; j++)
 
  204     hashValues[j] = RNIL;
 
  209 template <
typename P, 
typename T, 
typename U>
 
  214   const Uint32 hv = obj.p->hashValue() & mask;
 
  215   const Uint32 
i  = hashValues[hv];
 
  219     hashValues[hv] = obj.i;
 
  220     obj.p->U::nextHash = RNIL;
 
  221     obj.p->U::prevHash = RNIL;
 
  225     T * tmp = thePool.getPtr(i);
 
  226     tmp->U::prevHash = obj.i;
 
  227     obj.p->U::nextHash = 
i;
 
  228     obj.p->U::prevHash = RNIL;
 
  230     hashValues[hv] = obj.i;
 
  237 template <
typename P, 
typename T, 
typename U>
 
  243   while(i <= mask && hashValues[i] == RNIL) i++;
 
  247     iter.curr.i = hashValues[
i];
 
  248     iter.curr.p = thePool.getPtr(iter.curr.i);
 
  258 template <
typename P, 
typename T, 
typename U>
 
  263   if(iter.curr.p->U::nextHash == RNIL)
 
  265     Uint32 
i = iter.bucket + 1;
 
  266     while(i <= mask && hashValues[i] == RNIL) i++;
 
  270       iter.curr.i = hashValues[
i];
 
  271       iter.curr.p = thePool.getPtr(iter.curr.i);
 
  281   iter.curr.i = iter.curr.p->U::nextHash;
 
  282   iter.curr.p = thePool.getPtr(iter.curr.i);
 
  286 template <
typename P, 
typename T, 
typename U>
 
  291   const Uint32 hv = key.hashValue() & mask;  
 
  302     p = thePool.getPtr(i);
 
  305       const Uint32 
next = p->U::nextHash;
 
  308         hashValues[hv] = 
next;
 
  312         prev.p->U::nextHash = 
next;
 
  317         T * nextP = thePool.getPtr(next);
 
  318         nextP->U::prevHash = prev.i;
 
  332 template <
typename P, 
typename T, 
typename U>
 
  339   tmp.p = thePool.getPtr(i);
 
  343 template <
typename P, 
typename T, 
typename U>
 
  350   tmp.p = thePool.getPtr(i);
 
  354 template <
typename P, 
typename T, 
typename U>
 
  359   const Uint32 
next = ptr.p->U::nextHash;
 
  360   const Uint32 prev = ptr.p->U::prevHash;
 
  364     T * prevP = thePool.getPtr(prev);
 
  365     prevP->U::nextHash = 
next;
 
  369     const Uint32 hv = ptr.p->hashValue() & mask;  
 
  370     if (hashValues[hv] == ptr.i)
 
  372       hashValues[hv] = 
next;
 
  383     T * nextP = thePool.getPtr(next);
 
  384     nextP->U::prevHash = prev;
 
  388 template <
typename P, 
typename T, 
typename U>
 
  393   const Uint32 
next = ptr.p->U::nextHash;
 
  394   const Uint32 prev = ptr.p->U::prevHash;
 
  398     T * prevP = thePool.getPtr(prev);
 
  399     prevP->U::nextHash = 
next;
 
  403     const Uint32 hv = ptr.p->hashValue() & mask;  
 
  404     if (hashValues[hv] == ptr.i)
 
  406       hashValues[hv] = 
next;
 
  417     T * nextP = thePool.getPtr(next);
 
  418     nextP->U::prevHash = prev;
 
  421   thePool.release(ptr);
 
  424 template <
typename P, 
typename T, 
typename U>
 
  429   for(Uint32 
i = 0; 
i<=mask; 
i++)
 
  430     hashValues[
i] = RNIL;
 
  433 template <
typename P, 
typename T, 
typename U>
 
  438   while (bucket <= mask && hashValues[bucket] == RNIL) 
 
  443     iter.bucket = bucket;
 
  448   iter.bucket = bucket;
 
  449   iter.curr.i = hashValues[bucket];
 
  450   iter.curr.p = thePool.getPtr(iter.curr.i);
 
  454 template <
typename P, 
typename T, 
typename U>
 
  459   if(thePool.seize(ptr)){
 
  460     ptr.p->U::nextHash = ptr.p->U::prevHash = RNIL;
 
  466 template <
typename P, 
typename T, 
typename U>
 
  472   ptr.p = thePool.getPtr(i);
 
  475 template <
typename P, 
typename T, 
typename U>
 
  483 template <
typename P, 
typename T, 
typename U>
 
  488   return thePool.getPtr(i);
 
  491 template <
typename P, 
typename T, 
typename U>
 
  496   const Uint32 hv = key.hashValue() & mask;  
 
  504     p = thePool.getPtr(i);
 
  520 template <
typename T, 
typename U = T>