generalSimpleHashTable.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
generalSimpleHashTable.h
Go to the documentation of this file.
1 /* generalSimpleHashTable.h
2 */
3 #ifndef _GENERALSIMPLE_HASHTABLE_H
4 #define _GENERALSIMPLE_HASHTABLE_H
5
6 #include <boost/scoped_ptr.hpp>
7 #include <stdexcept>
8
9 namespace osl
10 {
11 namespace hash
12 {
13 class HashKey;
14 }
15 namespace container
16 {
17 struct TableFull : std::runtime_error
18 {
19 TableFull() : std::runtime_error("table full")
20 {
21 }
22 };
23
38 template <typename Record>
39 class GeneralSimpleHashTable
40 {
41 protected:
42 struct Table;
43 boost::scoped_ptr<Table> table;
44 public:
45 typedef hash::HashKey HashKey;
46
50 explicit GeneralSimpleHashTable(size_t capacity=100000);
51 ~GeneralSimpleHashTable();
52 void clear();
53
61 Record *allocate(const HashKey& key);
68 Record *find(const HashKey& key);
69 const Record *find(const HashKey& key) const;
70
71 size_t size() const;
72 size_t capacity() const;
73 int numCacheHit() const;
74 int numRecordAfterFull() const;
75
76 bool isVerbose() const;
78 int divSize() const;
79 };
80 } // namespace container
81 using container::TableFull;
82 using container::GeneralSimpleHashTable;
83 } // namespace osl
84
85 #endif /* _GENERALSIMPLE_HASHTABLE_H_ */
86 // ;;; Local Variables:
87 // ;;; mode:c++
88 // ;;; c-basic-offset:2
89 // ;;; End: