~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to storage/ndb/src/kernel/vm/DLCHashTable.hpp

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2013-12-22 10:27:05 UTC
  • Revision ID: package-import@ubuntu.com-20131222102705-mndw7s12mz0szrcn
Tags: upstream-5.5.32
Import upstream version 5.5.32

Show diffs side-by-side

added added

removed removed

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