home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / BOCOLE.PAK / HASHTBL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  857 b   |  37 lines

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