31 void *
Get(uint32_t key)
const;
35 bool Add(uint32_t key,
void *content);
38 void *
Remove(uint32_t key);
45 bool Rehash(uint32_t num_buckets);
54 #ifdef TB_RUNTIME_DEBUG_INFO
62 virtual void DeleteContent(
void * ) { assert(!
"You need to subclass and implement!"); }
71 uint32_t m_num_buckets;
81 void *GetNextContent();
84 uint32_t m_current_bucket;
85 TBHashTable::ITEM *m_current_item;
94 T *GetNextContent() {
return (T*) TBHashTableIterator::GetNextContent(); }
125 #endif // TB_HASHTABLE_H
TBHashTableOf is a TBHashTable with the given class type as content.
Definition: tb_hashtable.h:112
bool NeedRehash() const
Return true if the hashtable itself think it's time to rehash.
Definition: tb_hashtable.cpp:82
virtual void DeleteContent(void *content)
Delete the content of a item.
Definition: tb_hashtable.h:106
TBHashTableIterator is a iterator for stepping through all content stored in a TBHashTable.
Definition: tb_hashtable.h:77
virtual void DeleteContent(void *)
Delete the content of a item.
Definition: tb_hashtable.h:62
bool Add(uint32_t key, void *content)
Add content with the given key.
Definition: tb_hashtable.cpp:111
void * Remove(uint32_t key)
Remove the content with the given key.
Definition: tb_hashtable.cpp:129
TBHashTableIteratorOf is a TBHashTableIterator which auto cast to the class type. ...
Definition: tb_hashtable.h:90
TBHashTableOf is a TBHashTable with the given class type as content.
Definition: tb_hashtable.h:99
bool Rehash(uint32_t num_buckets)
Rehash the table so use the given number of buckets.
Definition: tb_hashtable.cpp:52
void Delete(uint32_t key)
Delete the content with the given key.
Definition: tb_hashtable.cpp:155
uint32_t GetSuitableBucketsCount() const
Get the number of buckets the hashtable itself thinks is suitable for the current number of items...
Definition: tb_hashtable.cpp:88
virtual void DeleteContent(void *content)
Delete the content of a item.
Definition: tb_hashtable.h:120
void RemoveAll()
Remove all items without deleting the content.
Definition: tb_hashtable.h:23
void DeleteAll()
Remove all items and delete the content.
Definition: tb_hashtable.h:28
void * Get(uint32_t key) const
Get the content for the given key, or nullptr if not found.
Definition: tb_hashtable.cpp:96
TBHashTable is a minimal hash table, for hashing anything using a uint32_t key.
Definition: tb_hashtable.h:16