Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. // File: hashTable.h
  2. // Definition of Hash Table Template Class
  3.  
  4. #ifndef HASH_TABLE_H
  5. #define HASH_TABLE_H
  6.  
  7. // Specification of the class
  8.  
  9. template <class keyType, class dataType>
  10.  
  11. class hashTable
  12. {
  13. public:
  14.  
  15. // Member Functions
  16. hashTable(int nelements = 11); // Constructor
  17. ~hashTable(); // Destructor
  18.  
  19. // Functions Prototype Definitions
  20.  
  21. void emptyTable(const keyType & );
  22. bool tableIsEmpty() const;
  23. bool tableIsFull() const;
  24. bool insert(const keyType &, const dataType & );
  25. bool search(const keyType & );
  26.  
  27. private:
  28.  
  29. // Slot Class
  30. class slot
  31. {
  32. public:
  33. keyType key; // key
  34. dataType data; // Data
  35. }; // end of class slot declaration
  36.  
  37. slot *T; // Pointer to Storage Array
  38. int h; // Index to a slot
  39. int MaxSize, csize; // Maximum and Current Sizes
  40. keyType Empty; // empty symbol
  41.  
  42. // Private Member function
  43. int hash(const keyType & ) const;
  44. };
  45. #endif // HASH_TABLE_H
  46. #include "hashTable.cpp"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement