1 #ifndef _GEMFIRE_HASHMAPT_HPP_ 2 #define _GEMFIRE_HASHMAPT_HPP_ 12 #include "gfcpp_globals.hpp" 26 template<
typename TKEY,
typename TVAL >
class HashMapT 51 inline const TKEY first( )
const 53 return staticCast<TKEY>( m_iter.first( ) );
56 inline const TVAL second( )
const 58 return staticCast<TVAL>( m_iter.second( ) );
61 inline Iterator& operator ++ ( )
67 inline void operator ++ (
int )
72 inline bool operator == (
const Iterator& other )
const 74 return ( m_iter == other.m_iter );
77 inline bool operator != (
const Iterator& other )
const 79 return ( m_iter != other.m_iter );
89 return gemfire::hashFunction< TKEY >( staticCast<TKEY>( p ) );
94 return gemfire::equalToFunction< TKEY >( staticCast<TKEY>( x ),
95 staticCast<TKEY>( y ) );
99 inline int32_t
size()
const 101 return static_cast<int32_t
> (m_map.
size());
107 return static_cast<int32_t
>(m_map.
max_size());
113 return m_map.
empty( );
131 m_map.
swap( other.m_map );
137 inline bool insert(
const TKEY& k,
const TVAL& v )
139 return m_map.
insert( k, v );
143 inline void update(
const TKEY& k,
const TVAL& v )
149 inline int32_t
erase(
const TKEY& k )
151 return m_map.
erase( k );
167 inline Iterator
find(
const TKEY& k )
const 169 return Iterator( m_map.
find( k ) );
175 return m_map.
count( k );
183 return staticCast<TVAL>( m_map[ k ] );
189 return Iterator( m_map.
begin( ) );
193 inline Iterator
end( )
const 195 return Iterator( m_map.
end( ) );
209 : m_map( hasher, equal_to )
217 : m_map( n, hasher, equal_to )
223 : m_map( other.m_map )
249 _HashMapOfCacheable() { }
253 _HashMapOfCacheable(n) { }
257 _HashMapOfCacheable(other) { }
276 _HashMapOfException() { }
280 _HashMapOfException(n) { }
284 _HashMapOfException(other) { }
Interface of an iterator for HashMapOfSharedBase.
Definition: HashMapOfSharedBase.hpp:52
bool empty() const
true if the hash_map's size is 0.
void clear()
Erases all of the elements.
Definition: HashMapT.hpp:155
Iterator find(const SharedBasePtr &k) const
Finds an element whose key is k.
void update(const TKEY &k, const TVAL &v)
Updates a value whose key must exist.
Definition: HashMapT.hpp:143
int32_t count(const SharedBasePtr &k) const
Counts the number of elements whose key is k.
Definition: HashMapT.hpp:173
Iterator end() const
Get an iterator pointing to the end of hash_map.
Represents a HashMap of SharedBase
Definition: HashMapOfSharedBase.hpp:39
void swap(HashMapOfSharedBase &other)
Swaps the contents of two hash_maps.
bool contains(const SharedBasePtr &k) const
Check if a given key k exists in the hash_map.
int32_t max_size() const
Returns the largest possible size of the hash_map.
HashMapOfCacheable(int32_t n)
Creates an empty hash map with at least n buckets.
Definition: HashMapT.hpp:252
bool contains(const TKEY &k) const
Check if a given key k exists in the hash map.
Definition: HashMapT.hpp:161
Iterator end() const
Get an iterator pointing to the end of hash_map.
Definition: HashMapT.hpp:193
HashMapT()
Creates an empty hash map with hash function hasher<TKEY> and equal to function equal_to<TKEY>.
Definition: HashMapT.hpp:208
bool empty() const
true if the hash map's size is 0.
Definition: HashMapT.hpp:111
HashMapT & operator=(const HashMapT &other)
Assignment operator.
Definition: HashMapT.hpp:199
A map of CacheableKey objects to Exception that also extends SharedBase for smart pointers...
Definition: HashMapT.hpp:267
~HashMapT()
Destructor: the destructor of m_map would do required stuff.
Definition: HashMapT.hpp:228
int32_t erase(const TKEY &k)
Erases the element whose key is k.
Definition: HashMapT.hpp:149
HashMapOfCacheable()
Creates an empty hash map.
Definition: HashMapT.hpp:248
TVAL operator[](const TKEY &k)
Returns a copy of the object that is associated with a particular key.
Definition: HashMapT.hpp:181
HashMapOfCacheable(const HashMapOfCacheable &other)
Copy constructor.
Definition: HashMapT.hpp:256
void swap(HashMapT &other)
Swaps the contents of two hash maps.
Definition: HashMapT.hpp:129
HashMapT(const HashMapT &other)
Copy constructor.
Definition: HashMapT.hpp:222
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
HashMap of TKEY to TVAL.
Definition: HashMapT.hpp:26
HashMapOfException(const HashMapOfException &other)
Copy constructor.
Definition: HashMapT.hpp:283
bool insert(const TKEY &k, const TVAL &v)
Inserts the <k, v> pair into the hash map, when k does not exist in the hash map. ...
Definition: HashMapT.hpp:137
Iterator find(const TKEY &k) const
Finds an element whose key is k.
Definition: HashMapT.hpp:167
A map of CacheableKey objects to Cacheable that also extends SharedBase for smart pointers...
Definition: HashMapT.hpp:240
int32_t max_size() const
Returns the largest possible size of the hash map.
Definition: HashMapT.hpp:105
int32_t erase(const SharedBasePtr &k)
Erases the element whose key is k.
void clear()
Erases all of the elements.
Iterator begin() const
Get an iterator pointing to the start of hash_map.
void resize(int32_t n)
Increases the bucket count to at least n.
int32_t size() const
Returns the size of the hash map.
Definition: HashMapT.hpp:99
HashMapT(int32_t n)
Creates an empty hash map with at least n buckets and hash function hasher<TKEY> and equal to functio...
Definition: HashMapT.hpp:216
_HashMapOfException::Iterator Iterator
Iterator class for the hash map.
Definition: HashMapT.hpp:272
#define CPPCACHE_EXPORT
Defines a GemFire CPPCACHE export.
Definition: gf_base.hpp:51
This abstract base class is the base class of all user objects that have the shared capability of ref...
Definition: SharedBase.hpp:31
HashMapOfException()
Creates an empty hash map.
Definition: HashMapT.hpp:275
int32_t bucket_count() const
Returns the number of buckets used by the hash_map.
bool insert(const SharedBasePtr &k, const SharedBasePtr &v)
Inserts the <k, v> pair into the hash_map, when k does not exist in the hash_map. ...
HashMapOfException(int32_t n)
Creates an empty hash map with at least n buckets.
Definition: HashMapT.hpp:279
int32_t bucket_count() const
Returns the number of buckets used by the hash map.
Definition: HashMapT.hpp:117
void resize(int32_t n)
Increases the bucket count to at least n.
Definition: HashMapT.hpp:123
int32_t count(const SharedBasePtr &k) const
Counts the number of elements whose key is k.
_HashMapOfCacheable::Iterator Iterator
Iterator class for the hash map.
Definition: HashMapT.hpp:245
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:35
int32_t size() const
Returns the size of the hash_map.
Iterator begin() const
Get an iterator pointing to the start of hash_map.
Definition: HashMapT.hpp:187