diff options
Diffstat (limited to 'core/hash_map.h')
-rw-r--r-- | core/hash_map.h | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/core/hash_map.h b/core/hash_map.h index e40b00a67a..f27a86cc02 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -197,14 +197,14 @@ private: e = e->next; } - return NULL; + return nullptr; } Element *create_element(const TKey &p_key) { /* if element doesn't exist, create it */ Element *e = memnew(Element); - ERR_FAIL_COND_V_MSG(!e, NULL, "Out of memory."); + ERR_FAIL_COND_V_MSG(!e, nullptr, "Out of memory."); uint32_t hash = Hasher::hash(p_key); uint32_t index = hash & ((1 << hash_table_power) - 1); e->next = hash_table[index]; @@ -234,7 +234,7 @@ private: for (int i = 0; i < (1 << p_t.hash_table_power); i++) { - hash_table[i] = NULL; + hash_table[i] = nullptr; const Element *e = p_t.hash_table[i]; @@ -260,7 +260,7 @@ public: Element *set(const Pair &p_pair) { - Element *e = NULL; + Element *e = nullptr; if (!hash_table) make_hash_table(); // if no table, make one else @@ -272,7 +272,7 @@ public: e = create_element(p_pair.key); if (!e) - return NULL; + return nullptr; check_hash_table(); // perform mantenience routine } @@ -282,12 +282,12 @@ public: bool has(const TKey &p_key) const { - return getptr(p_key) != NULL; + return getptr(p_key) != nullptr; } /** * Get a key from data, return a const reference. - * WARNING: this doesn't check errors, use either getptr and check NULL, or check + * WARNING: this doesn't check errors, use either getptr and check nullptr, or check * first with has(key) */ @@ -306,38 +306,38 @@ public: } /** - * Same as get, except it can return NULL when item was not found. + * Same as get, except it can return nullptr when item was not found. * This is mainly used for speed purposes. */ _FORCE_INLINE_ TData *getptr(const TKey &p_key) { if (unlikely(!hash_table)) - return NULL; + return nullptr; Element *e = const_cast<Element *>(get_element(p_key)); if (e) return &e->pair.data; - return NULL; + return nullptr; } _FORCE_INLINE_ const TData *getptr(const TKey &p_key) const { if (unlikely(!hash_table)) - return NULL; + return nullptr; const Element *e = const_cast<Element *>(get_element(p_key)); if (e) return &e->pair.data; - return NULL; + return nullptr; } /** - * Same as get, except it can return NULL when item was not found. + * Same as get, except it can return nullptr when item was not found. * This version is custom, will take a hash and a custom key (that should support operator==() */ @@ -345,7 +345,7 @@ public: _FORCE_INLINE_ TData *custom_getptr(C p_custom_key, uint32_t p_custom_hash) { if (unlikely(!hash_table)) - return NULL; + return nullptr; uint32_t hash = p_custom_hash; uint32_t index = hash & ((1 << hash_table_power) - 1); @@ -364,14 +364,14 @@ public: e = e->next; } - return NULL; + return nullptr; } template <class C> _FORCE_INLINE_ const TData *custom_getptr(C p_custom_key, uint32_t p_custom_hash) const { if (unlikely(!hash_table)) - return NULL; + return nullptr; uint32_t hash = p_custom_hash; uint32_t index = hash & ((1 << hash_table_power) - 1); @@ -390,7 +390,7 @@ public: e = e->next; } - return NULL; + return nullptr; } /** @@ -406,7 +406,7 @@ public: uint32_t index = hash & ((1 << hash_table_power) - 1); Element *e = hash_table[index]; - Element *p = NULL; + Element *p = nullptr; while (e) { /* checking hash first avoids comparing key, which may take longer */ @@ -443,7 +443,7 @@ public: } inline TData &operator[](const TKey &p_key) { //assignment - Element *e = NULL; + Element *e = nullptr; if (!hash_table) make_hash_table(); // if no table, make one else @@ -462,12 +462,12 @@ public: /** * Get the next key to p_key, and the first key if p_key is null. - * Returns a pointer to the next key if found, NULL otherwise. + * Returns a pointer to the next key if found, nullptr otherwise. * Adding/Removing elements while iterating will, of course, have unexpected results, don't do it. * * Example: * - * const TKey *k=NULL; + * const TKey *k=nullptr; * * while( (k=table.next(k)) ) { * @@ -478,7 +478,7 @@ public: const TKey *next(const TKey *p_key) const { if (unlikely(!hash_table)) - return NULL; + return nullptr; if (!p_key) { /* get the first key */ @@ -492,7 +492,7 @@ public: } else { /* get the next key */ const Element *e = get_element(*p_key); - ERR_FAIL_COND_V_MSG(!e, NULL, "Invalid key supplied."); + ERR_FAIL_COND_V_MSG(!e, nullptr, "Invalid key supplied."); if (e->next) { /* if there is a "next" in the list, return that */ return &e->next->pair.key; @@ -511,7 +511,7 @@ public: /* nothing found, was at end */ } - return NULL; /* nothing found */ + return nullptr; /* nothing found */ } inline unsigned int size() const { @@ -552,7 +552,7 @@ public: } HashMap() { - hash_table = NULL; + hash_table = nullptr; elements = 0; hash_table_power = 0; } @@ -586,7 +586,7 @@ public: HashMap(const HashMap &p_table) { - hash_table = NULL; + hash_table = nullptr; elements = 0; hash_table_power = 0; |