Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb::TBHashTable Class Reference

TBHashTable is a minimal hash table, for hashing anything using a uint32_t key. More...

#include <tb_hashtable.h>

Inheritance diagram for tb::TBHashTable:
tb::TBHashTableAutoDeleteOf< T > tb::TBHashTableOf< T > tb::TBHashTableAutoDeleteOf< tb::TBFontFace > tb::TBHashTableAutoDeleteOf< tb::TBFontGlyph > tb::TBHashTableAutoDeleteOf< tb::TBFontInfo > tb::TBHashTableAutoDeleteOf< tb::TBSkinElement > tb::TBHashTableAutoDeleteOf< tb::TBWidgetValue > tb::TBHashTableOf< tb::TBBitmapFragment > tb::TBHashTableOf< tb::TBStr >

Public Member Functions

void RemoveAll ()
 Remove all items without deleting the content. More...
 
void DeleteAll ()
 Remove all items and delete the content. More...
 
void * Get (uint32_t key) const
 Get the content for the given key, or nullptr if not found. More...
 
bool Add (uint32_t key, void *content)
 Add content with the given key. More...
 
void * Remove (uint32_t key)
 Remove the content with the given key. More...
 
void Delete (uint32_t key)
 Delete the content with the given key. More...
 
bool Rehash (uint32_t num_buckets)
 Rehash the table so use the given number of buckets. More...
 
bool NeedRehash () const
 Return true if the hashtable itself think it's time to rehash. More...
 
uint32_t GetSuitableBucketsCount () const
 Get the number of buckets the hashtable itself thinks is suitable for the current number of items. More...
 

Protected Member Functions

virtual void DeleteContent (void *)
 Delete the content of a item. More...
 

Friends

class TBHashTableIterator
 

Detailed Description

TBHashTable is a minimal hash table, for hashing anything using a uint32_t key.

Member Function Documentation

bool tb::TBHashTable::Add ( uint32_t  key,
void *  content 
)

Add content with the given key.

Returns false if out of memory.

void tb::TBHashTable::Delete ( uint32_t  key)

Delete the content with the given key.

void tb::TBHashTable::DeleteAll ( )
inline

Remove all items and delete the content.

This requires TBHashTable to be subclassed and implementing DeleteContent. You would typically do this by using TBHashTableOf or TBHashTableAutoDeleteOf.

virtual void tb::TBHashTable::DeleteContent ( void *  )
inlineprotectedvirtual
void * tb::TBHashTable::Get ( uint32_t  key) const

Get the content for the given key, or nullptr if not found.

uint32_t tb::TBHashTable::GetSuitableBucketsCount ( ) const

Get the number of buckets the hashtable itself thinks is suitable for the current number of items.

bool tb::TBHashTable::NeedRehash ( ) const

Return true if the hashtable itself think it's time to rehash.

bool tb::TBHashTable::Rehash ( uint32_t  num_buckets)

Rehash the table so use the given number of buckets.

Returns false if out of memory.

void * tb::TBHashTable::Remove ( uint32_t  key)

Remove the content with the given key.

void tb::TBHashTable::RemoveAll ( )
inline

Remove all items without deleting the content.


The documentation for this class was generated from the following files: