home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / BOCOLE.PAK / HASHTBL.CPP < prev    next >
C/C++ Source or Header  |  1995-08-29  |  583b  |  35 lines

  1. //
  2.  
  3.  
  4. #include <hashtbl.h>
  5. #include <oledebug.h>
  6.  
  7.  
  8. template <class T, HashIndex SIZE>
  9. HashTable<T, SIZE>::~HashTable()
  10. {
  11.     IHashable<T> *pH, *pTmp;
  12.     for (HashIndex i=0; i < SIZE; i++) {
  13.         pH = aBuckets[i];
  14.         while (pH) {
  15.             pTmp = pH->Next();
  16.             pH -> Release();
  17.             pH = pTmp;
  18.         }
  19.     }
  20. }
  21.  
  22.  
  23. template <class T, HashIndex SIZE>
  24. IHashable<T> *&HashTable<T, SIZE>::Find(IHashable<T> *pKey)
  25. {
  26.     IHashable<T> **ppElem = &aBuckets[pKey->Hash(SIZE)];
  27.     while ((*ppElem != NULL) && (**ppElem != (T*) pKey)) {
  28.         ppElem = &(*ppElem)->Next();
  29.     }
  30.     return *ppElem;
  31. }
  32.  
  33.  
  34.  
  35.