00001 /* generalSimpleHashTable.h 00002 */ 00003 #ifndef _GENERALSIMPLE_HASHTABLE_H 00004 #define _GENERALSIMPLE_HASHTABLE_H 00005 00006 #include <boost/scoped_ptr.hpp> 00007 #include <stdexcept> 00008 00009 namespace osl 00010 { 00011 namespace hash 00012 { 00013 class HashKey; 00014 } 00015 namespace container 00016 { 00017 struct TableFull : std::runtime_error 00018 { 00019 TableFull() : std::runtime_error("table full") 00020 { 00021 } 00022 }; 00023 00038 template <typename Record> 00039 class GeneralSimpleHashTable 00040 { 00041 protected: 00042 class Table; 00043 boost::scoped_ptr<Table> table; 00044 public: 00045 typedef hash::HashKey HashKey; 00046 00050 explicit GeneralSimpleHashTable(unsigned int capacity=100000); 00051 ~GeneralSimpleHashTable(); 00052 void clear(); 00053 00061 Record *allocate(const HashKey& key); 00068 Record *find(const HashKey& key); 00069 const Record *find(const HashKey& key) const; 00070 00071 unsigned int size() const; 00072 unsigned int capacity() const; 00073 int numCacheHit() const; 00074 int numRecordAfterFull() const; 00075 00076 bool isVerbose() const; 00078 int divSize() const; 00079 }; 00080 } // namespace container 00081 using container::TableFull; 00082 using container::GeneralSimpleHashTable; 00083 } // namespace osl 00084 00085 #endif /* _GENERALSIMPLE_HASHTABLE_H_ */ 00086 // ;;; Local Variables: 00087 // ;;; mode:c++ 00088 // ;;; c-basic-offset:2 00089 // ;;; End: