VMware GemFire Native C++ Reference
9.2.4
|
Go to the documentation of this file.
3 #ifndef GEODE_HASHMAPT_H_
4 #define GEODE_HASHMAPT_H_
23 #include "geode_globals.hpp"
37 template <
typename TKEY,
typename TVAL>
53 inline const TKEY first()
const {
return staticCast<TKEY>(m_iter.first()); }
55 inline const TVAL second()
const {
56 return staticCast<TVAL>(m_iter.second());
59 inline Iterator& operator++() {
64 inline void operator++(
int) { m_iter++; }
66 inline bool operator==(
const Iterator& other)
const {
67 return (m_iter == other.m_iter);
70 inline bool operator!=(
const Iterator& other)
const {
71 return (m_iter != other.m_iter);
78 return apache::geode::client::hashFunction<TKEY>(staticCast<TKEY>(p));
82 return apache::geode::client::equalToFunction<TKEY>(staticCast<TKEY>(x),
87 inline int32_t
size()
const {
return static_cast<int32_t>(m_map.
size()); }
91 return static_cast<int32_t>(m_map.
max_size());
111 inline bool insert(
const TKEY& k,
const TVAL& v) {
112 return m_map.
insert(k, v);
116 inline void update(
const TKEY& k,
const TVAL& v) { m_map[k] = v; }
119 inline int32_t
erase(
const TKEY& k) {
return m_map.
erase(k); }
128 inline Iterator
find(
const TKEY& k)
const {
return Iterator(m_map.
find(k)); }
136 inline TVAL
operator[](
const TKEY& k) {
return staticCast<TVAL>(m_map[k]); }
139 inline Iterator
begin()
const {
return Iterator(m_map.
begin()); }
142 inline Iterator
end()
const {
return Iterator(m_map.
end()); }
158 inline HashMapT(int32_t n) : m_map(n, hasher, equal_to) {}
167 typedef HashMapT<CacheableKeyPtr, CacheablePtr> _HashMapOfCacheable;
168 typedef HashMapT<CacheableKeyPtr, ExceptionPtr> _HashMapOfException;
218 typedef SharedPtr<HashMapOfCacheable> HashMapOfCacheablePtr;
219 typedef SharedPtr<HashMapOfException> HashMapOfExceptionPtr;
224 #endif // GEODE_HASHMAPT_H_
HashMapT()
Creates an empty hash map with hash function hasher<TKEY> and equal to function equal_to<TKEY>.
Definition: HashMapT.hpp:153
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:111
TVAL operator[](const TKEY &k)
Returns a copy of the object that is associated with a particular key.
Definition: HashMapT.hpp:136
Represents a HashMap of SharedBase
Definition: HashMapOfSharedBase.hpp:48
void resize(int32_t n)
Increases the bucket count to at least n.
int32_t bucket_count() const
Returns the number of buckets used by the hash_map.
Each enum represents a predefined RegionAttributes in a {}.
Definition: Assert.hpp:31
int32_t size() const
Returns the size of the hash_map.
HashMapOfException()
Creates an empty hash map.
Definition: HashMapT.hpp:205
void resize(int32_t n)
Increases the bucket count to at least n.
Definition: HashMapT.hpp:103
int32_t erase(const SharedBasePtr &k)
Erases the element whose key is k.
Iterator find(const SharedBasePtr &k) const
Finds an element whose key is k.
HashMapOfException(int32_t n)
Creates an empty hash map with at least n buckets.
Definition: HashMapT.hpp:208
Iterator end() const
Get an iterator pointing to the end of hash_map.
Definition: HashMapT.hpp:142
bool empty() const
true if the hash map's size is 0.
Definition: HashMapT.hpp:95
HashMapOfCacheable()
Creates an empty hash map.
Definition: HashMapT.hpp:181
bool contains(const SharedBasePtr &k) const
Check if a given key k exists in the hash_map.
A map of CacheableKey objects to Cacheable that also extends SharedBase for smart pointers.
Definition: HashMapT.hpp:174
int32_t max_size() const
Returns the largest possible size of the hash_map.
int32_t count(const SharedBasePtr &k) const
Counts the number of elements whose key is k.
Iterator end() const
Get an iterator pointing to the end of hash_map.
void swap(HashMapT &other)
Swaps the contents of two hash maps.
Definition: HashMapT.hpp:106
Iterator begin() const
Get an iterator pointing to the start of hash_map.
Definition: HashMapT.hpp:139
void swap(HashMapOfSharedBase &other)
Swaps the contents of two hash_maps.
HashMap of TKEY to TVAL.
Definition: HashMapT.hpp:38
HashMapT(const HashMapT &other)
Copy constructor.
Definition: HashMapT.hpp:161
void clear()
Erases all of the elements.
Iterator begin() const
Get an iterator pointing to the start of hash_map.
int32_t size() const
Returns the size of the hash map.
Definition: HashMapT.hpp:87
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.
HashMapT & operator=(const HashMapT &other)
Assignment operator.
Definition: HashMapT.hpp:145
_HashMapOfCacheable::Iterator Iterator
Iterator class for the hash map.
Definition: HashMapT.hpp:178
int32_t erase(const TKEY &k)
Erases the element whose key is k.
Definition: HashMapT.hpp:119
~HashMapT()
Destructor: the destructor of m_map would do required stuff.
Definition: HashMapT.hpp:164
bool empty() const
true if the hash_map's size is 0.
Interface of an iterator for HashMapOfSharedBase.
Definition: HashMapOfSharedBase.hpp:57
int32_t max_size() const
Returns the largest possible size of the hash map.
Definition: HashMapT.hpp:90
#define CPPCACHE_EXPORT
Defines a Geode CPPCACHE export.
Definition: geode_base.hpp:58
void update(const TKEY &k, const TVAL &v)
Updates a value whose key must exist.
Definition: HashMapT.hpp:116
bool contains(const TKEY &k) const
Check if a given key k exists in the hash map.
Definition: HashMapT.hpp:125
Iterator find(const TKEY &k) const
Finds an element whose key is k.
Definition: HashMapT.hpp:128
void clear()
Erases all of the elements.
Definition: HashMapT.hpp:122
HashMapOfCacheable(int32_t n)
Creates an empty hash map with at least n buckets.
Definition: HashMapT.hpp:184
int32_t count(const SharedBasePtr &k) const
Counts the number of elements whose key is k.
Definition: HashMapT.hpp:131
Definition: SharedBase.hpp:40
int32_t bucket_count() const
Returns the number of buckets used by the hash map.
Definition: HashMapT.hpp:98
HashMapOfCacheable(const HashMapOfCacheable &other)
Copy constructor.
Definition: HashMapT.hpp:187
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:158
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:52
A map of CacheableKey objects to Exception that also extends SharedBase for smart pointers.
Definition: HashMapT.hpp:198
_HashMapOfException::Iterator Iterator
Iterator class for the hash map.
Definition: HashMapT.hpp:202
HashMapOfException(const HashMapOfException &other)
Copy constructor.
Definition: HashMapT.hpp:211
Pivotal GemFire C++ Cache API Documentation