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) {}
188 : _HashMapOfCacheable(other) {}
212 : _HashMapOfException(other) {}
224 #endif // GEODE_HASHMAPT_H_ Iterator find(const SharedBasePtr &k) const
Finds an element whose key is k.
HashMapOfCacheable()
Creates an empty hash map.
Definition: HashMapT.hpp:181
TVAL operator[](const TKEY &k)
Returns a copy of the object that is associated with a particular key.
Definition: HashMapT.hpp:136
HashMapOfException(int32_t n)
Creates an empty hash map with at least n buckets.
Definition: HashMapT.hpp:208
void update(const TKEY &k, const TVAL &v)
Updates a value whose key must exist.
Definition: HashMapT.hpp:116
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
HashMapOfException()
Creates an empty hash map.
Definition: HashMapT.hpp:205
Iterator end() const
Get an iterator pointing to the end of hash_map.
int32_t bucket_count() const
Returns the number of buckets used by the hash_map.
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
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
HashMapOfCacheable(int32_t n)
Creates an empty hash map with at least n buckets.
Definition: HashMapT.hpp:184
int32_t size() const
Returns the size of the hash map.
Definition: HashMapT.hpp:87
#define CPPCACHE_EXPORT
Defines a Geode CPPCACHE export.
Definition: geode_base.hpp:58
HashMapT(const HashMapT &other)
Copy constructor.
Definition: HashMapT.hpp:161
HashMapT()
Creates an empty hash map with hash function hasher<TKEY> and equal to function equal_to<TKEY>.
Definition: HashMapT.hpp:153
int32_t max_size() const
Returns the largest possible size of the hash_map.
Iterator begin() const
Get an iterator pointing to the start of hash_map.
Iterator begin() const
Get an iterator pointing to the start of hash_map.
Definition: HashMapT.hpp:139
HashMapT & operator=(const HashMapT &other)
Assignment operator.
Definition: HashMapT.hpp:145
Iterator end() const
Get an iterator pointing to the end of hash_map.
Definition: HashMapT.hpp:142
HashMap of TKEY to TVAL.
Definition: HashMapT.hpp:38
void resize(int32_t n)
Increases the bucket count to at least n.
int32_t erase(const TKEY &k)
Erases the element whose key is k.
Definition: HashMapT.hpp:119
HashMapOfCacheable(const HashMapOfCacheable &other)
Copy constructor.
Definition: HashMapT.hpp:187
void clear()
Erases all of the elements.
Definition: HashMapT.hpp:122
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:52
Interface of an iterator for HashMapOfSharedBase.
Definition: HashMapOfSharedBase.hpp:57
bool empty() const
true if the hash map's size is 0.
Definition: HashMapT.hpp:95
_HashMapOfException::Iterator Iterator
Iterator class for the hash map.
Definition: HashMapT.hpp:202
void swap(HashMapOfSharedBase &other)
Swaps the contents of two hash_maps.
void resize(int32_t n)
Increases the bucket count to at least n.
Definition: HashMapT.hpp:103
This abstract base class is the base class of all user objects that have the shared capability of ref...
Definition: SharedBase.hpp:40
int32_t count(const SharedBasePtr &k) const
Counts the number of elements whose key is k.
bool contains(const TKEY &k) const
Check if a given key k exists in the hash map.
Definition: HashMapT.hpp:125
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. ...
Represents a HashMap of SharedBase
Definition: HashMapOfSharedBase.hpp:48
bool contains(const SharedBasePtr &k) const
Check if a given key k exists in the hash_map.
int32_t count(const SharedBasePtr &k) const
Counts the number of elements whose key is k.
Definition: HashMapT.hpp:131
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.
Definition: HashMapT.hpp:90
HashMapOfException(const HashMapOfException &other)
Copy constructor.
Definition: HashMapT.hpp:211
int32_t bucket_count() const
Returns the number of buckets used by the hash map.
Definition: HashMapT.hpp:98
int32_t erase(const SharedBasePtr &k)
Erases the element whose key is k.
bool empty() const
true if the hash_map's size is 0.
int32_t size() const
Returns the size of the hash_map.
_HashMapOfCacheable::Iterator Iterator
Iterator class for the hash map.
Definition: HashMapT.hpp:178
Iterator find(const TKEY &k) const
Finds an element whose key is k.
Definition: HashMapT.hpp:128
void swap(HashMapT &other)
Swaps the contents of two hash maps.
Definition: HashMapT.hpp:106
~HashMapT()
Destructor: the destructor of m_map would do required stuff.
Definition: HashMapT.hpp:164
A map of CacheableKey objects to Exception that also extends SharedBase for smart pointers...
Definition: HashMapT.hpp:198
This namespace contains all the Geode C++ API classes, enumerations and globals.
void clear()
Erases all of the elements.