HashTable.h
Go to the documentation of this file.00001 00015 #ifndef __HashTable_H__ 00016 #define __HashTable_H__ 00017 00018 // Includes 00019 00020 // Forward declares 00021 template<class HASHTABLEKEY, class TYPE> class HashTableIterator; 00022 00023 // HashTable 00024 template<class HASHTABLEKEY, class TYPE> 00025 class HashTable 00026 { 00027 public: 00031 HashTable( 00032 int initialSlots = 64 00033 ); 00034 00035 00039 ~HashTable(); 00040 00041 00045 void Insert( 00046 const HASHTABLEKEY& key, 00047 const TYPE& data 00048 ); 00049 00053 void Remove( 00054 const HASHTABLEKEY& key 00055 ); 00056 00060 void Remove( 00061 const HashTableIterator<HASHTABLEKEY,TYPE>& iterator 00062 ); 00063 00064 00070 int GetItemCount() const; 00071 00072 00077 void Clear( 00078 bool releaseMemory = false 00079 ); 00080 00081 private: 00082 friend class HashTableIterator<HASHTABLEKEY,TYPE>; 00083 00085 struct HashTableItem 00086 { 00087 HASHTABLEKEY key; 00088 TYPE data; 00089 bool inUse; 00090 int itemCount; 00091 00092 HashTableItem():inUse(false),itemCount(0) {} 00093 }; 00094 private: 00095 int initialSlots_; 00096 int slotCount_; 00097 int itemCount_; 00098 HashTableItem* items_; 00099 }; 00100 00101 00102 // Implementation 00103 #include "HashTable.inl" 00104 00105 #endif /* __HASHTABLE_H__ */
Reproduction/republishing of any material on this site without permission is strictly prohibited.
