CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
hashtable.h File Reference

Hash table container with type-safe generic key-value storage. More...

#include <cx/cx.h>
#include <cx/debug/assert.h>

Go to the source code of this file.

Macros

#define htSize(ref)   ((ref) ? _htHdr((ref))->valid : 0)
 
#define htKeyType(ref)   ((ref) ? _htHdr((ref))->keytype : 0)
 
#define htValType(ref)   ((ref) ? _htHdr((ref))->valtype : 0)
 
#define hteKeyPtrHdr(hdr, type, elem)   ((stStorageType(type)*)_hteElemKeyPtr(hdr, elem))
 
#define hteValPtrHdr(hdr, type, elem)   ((stStorageType(type)*)_hteElemValPtr(hdr, elem))
 
#define hteKeyPtr(ref, type, elem)   hteKeyPtrHdr(_htHdr(ref), type, elem)
 
#define hteValPtr(ref, type, elem)   hteValPtrHdr(_htHdr(ref), type, elem)
 
#define hteKey(ref, type, elem)   (*hteKeyPtr(ref, type, elem))
 
#define hteVal(ref, type, elem)   (*hteValPtr(ref, type, elem))
 
#define htiKeyPtr(type, iter)   (hteKeyPtrHdr((iter).hdr, type, (iter).slot))
 
#define htiValPtr(type, iter)   (hteValPtrHdr((iter).hdr, type, (iter).slot))
 
#define htiKey(type, iter)   (*htiKeyPtr(type, iter))
 
#define htiVal(type, iter)   (*htiValPtr(type, iter))
 
#define HT_Grow(flag)   (((uint32)HT_GROW_##flag) << 24)
 
#define htInit(out, keytype, valtype, initsz, ...)    _htInit(out, stFullType(keytype), stFullType(valtype), initsz, opt_flags(__VA_ARGS__))
 
#define htInsert(htbl, ktype, key, vtype, val, ...)
 
#define htInsertC(htbl, ktype, key, vtype, val, ...)
 
#define htFind(htbl, ktype, key, vtype, val_copy_out, ...)
 
#define htExtract(htbl, ktype, key, vtype, val_copy_out)    _htExtractChecked(htbl, stCheckedArg(ktype, key), stCheckedPtrArg(vtype, val_copy_out))
 
#define htRemove(htbl, ktype, key)    _htExtractChecked(htbl, stCheckedArg(ktype, key), stType(none), NULL)
 
#define htHasKey(htbl, ktype, key)   _htHasKeyChecked(htbl, stCheckedArg(ktype, key))
 

Typedefs

typedef struct hashtable_ref * hashtable
 

Enumerations

enum  HASHTABLE_FLAGS_ENUM {
  HT_CaseInsensitive = 0x0001 , HT_RefKeys = 0x0002 , HT_Ref = 0x0004 , HT_InsertOpt = 0x0008 ,
  HT_Compact = 0x0010 , HTINT_Metadata = 0x1000 , HTINT_Quadratic = 0x2000 , HTINT_Pow2 = 0x4000 ,
  HTINT_Extended = 0x8000
}
 Hash table configuration flags. More...
 
enum  HASHTABLE_FUNC_FLAGS_ENUM { HT_Ignore = 0x00010000 , HT_Borrow = 0x00020000 , HTINT_Consume = 0x10000000 }
 Function-specific flags. More...
 

Functions

void htDestroy (hashtable *htbl)
 
void htClear (hashtable *htbl)
 
void htReindex (hashtable *htbl, uint32 minsz)
 
void htRepack (hashtable *htbl)
 
void htClone (hashtable *out, hashtable ref)
 
_htiInitAnno bool htiInit (htiter *iter, hashtable htbl)
 
_htiNextAnno bool htiNext (htiter *iter)
 
void htiFinish (htiter *iter)
 
bool htiValid (htiter *iter)
 

Detailed Description

Hash table container with type-safe generic key-value storage.

Uses open addressing with configurable probing strategy and chunked storage allocation

Definition in file hashtable.h.