VMware GemFire Native Client Cache Reference  9.0.6
HashFunction.hpp
Go to the documentation of this file.
1 #ifndef _GEMFIRE_HASHFUNCTION_HPP_
2 #define _GEMFIRE_HASHFUNCTION_HPP_
3 
4 
5 /*=========================================================================
6  * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
7  * This product is protected by U.S. and international copyright
8  * and intellectual property laws. Pivotal products are covered by
9  * more patents listed at http://www.pivotal.io/patents.
10  *========================================================================
11  */
12 
13 #include "gfcpp_globals.hpp"
14 #include "SharedPtr.hpp"
15 #include "CacheableKey.hpp"
16 
17 
21 namespace gemfire
22 {
23 
25  typedef int32_t (*Hasher) ( const SharedBasePtr& );
26 
28  typedef bool (*EqualTo) ( const SharedBasePtr&, const SharedBasePtr& );
29 
30 
31  class HashSB
32  {
33  private:
34 
35  Hasher m_hashFn;
36 
37  // Never defined.
38  HashSB( );
39 
40 
41  public:
42 
43  HashSB( const Hasher hashFn )
44  : m_hashFn( hashFn )
45  {
46  }
47 
48  int32_t operator () ( const SharedBasePtr& p ) const
49  {
50  return m_hashFn( p );
51  }
52  };
53 
54 
55  class EqualToSB
56  {
57  private:
58 
59  EqualTo m_equalFn;
60 
61  // Never defined.
62  EqualToSB( );
63 
64 
65  public:
66 
67  EqualToSB( const EqualTo equalFn)
68  : m_equalFn( equalFn )
69  {
70  }
71 
72  bool operator () ( const SharedBasePtr& x, const SharedBasePtr& y ) const
73  {
74  return m_equalFn( x, y );
75  }
76  };
77 
78 
79  template < typename TKEY >
80  inline int32_t hashFunction( const TKEY& k )
81  {
82  return k->hashcode( );
83  }
84 
85  template < typename TKEY >
86  inline bool equalToFunction( const TKEY& x, const TKEY& y )
87  {
88  return ( *x.ptr( ) == *y.ptr( ) );
89  }
90 
91 }
92 
93 
94 #endif
bool(* EqualTo)(const SharedBasePtr &, const SharedBasePtr &)
typedef for the hashing key equality function.
Definition: HashFunction.hpp:28
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
int32_t(* Hasher)(const SharedBasePtr &)
typedef for the hash function used by the hashing schemes.
Definition: HashFunction.hpp:25
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:35

GemFire C++ Cache API Documentation