home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / contain / hash.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-21  |  1.4 KB  |  47 lines

  1. #ifndef __HASH_H
  2. #define __HASH_H
  3. // ╔════════════════════════════════════════════════╗
  4. // ║ hash.h, hash.cpp                               ║
  5. // ╟────────────────────────────────────────────────╢
  6. // ║ Hash tables                                    ║
  7. // ╟────────────────────────────────────────────────╢
  8. // ║ Written by Gus Smedstad                        ║
  9. // ╟────────────────────────────────────────────────╢
  10. // ║ Copyright 1990-91 NoGate Consulting            ║
  11. // ╚════════════════════════════════════════════════╝
  12.  
  13. #ifndef __DOUBLE_H
  14. #include "double.h"
  15. #endif
  16.  
  17. class hash_table : public container {
  18.   friend class hash_index;
  19.   unsigned      table_size;
  20.   double_list **table;
  21. public:
  22.   hash_table(int t_size);
  23.   virtual ~hash_table();
  24.   void       empty(char kill = 0);
  25.  
  26.   void       put(hashable *arg);
  27.   hashable  *remove(hashable *arg);
  28.   int        has(hashable *arg, int exact = 1);
  29.  };
  30.  
  31. class hash_index : public double_index {
  32.   hash_table  *table;
  33.   unsigned     hash_number;
  34. public:
  35.   hash_index(hash_table & base);
  36.   void         attach(hash_table &base);
  37.   void         rewind();
  38.   void         to_end();
  39.   int          has(hashable *arg, int exact = 1);
  40.   void         destroy();
  41.   hashable    *remove();
  42.   hashable    *value() const { return (hashable *) item(); };
  43.   void         operator ++ ( int );
  44.   void         operator -- ( int );
  45.  };
  46.  
  47. #endif