MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DLCHashTable.hpp
1 /*
2  Copyright (C) 2005, 2006 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef DLC_HASHTABLE_HPP
20 #define DLC_HASHTABLE_HPP
21 
22 #include <ndb_global.h>
23 #include "DLHashTable.hpp"
24 
25 // Adds "count" to DLHashTable
26 template <class T, class U = T>
27 class DLCHashTable : public DLHashTable<T, U> {
28 public:
29  // Ctor
30  DLCHashTable(ArrayPool<T> & thePool) :
31  DLHashTable<T, U>(thePool),
32  m_count(0)
33  {}
34 
35  // Get count
36  Uint32 count() const { return m_count; }
37 
38  // Redefine methods which do add or remove
39 
40  void add(Ptr<T>& ptr) {
42  m_count++;
43  }
44 
45  void remove(Ptr<T>& ptr, const T & key) {
46  DLHashTable<T, U>::remove(ptr, key);
47  m_count--;
48  }
49 
50  void remove(Uint32 i) {
52  m_count--;
53  }
54 
55  void remove(Ptr<T>& ptr) {
57  m_count--;
58  }
59 
60  void removeAll() {
62  m_count = 0;
63  }
64 
65  void release(Ptr<T>& ptr, const T & key) {
67  m_count--;
68  }
69 
70  void release(Uint32 i) {
72  m_count--;
73  }
74 
75  void release(Ptr<T>& ptr) {
77  m_count--;
78  }
79 
80 private:
81  Uint32 m_count;
82 };
83 
84 #endif