2014-10-12 07:44:45 +00:00
|
|
|
#ifndef TABLE_H
|
|
|
|
#define TABLE_H
|
|
|
|
|
|
|
|
#include "util/common.h"
|
|
|
|
|
|
|
|
struct TableList;
|
|
|
|
|
|
|
|
struct Table {
|
|
|
|
struct TableList* table;
|
|
|
|
size_t tableSize;
|
2014-11-01 10:02:10 +00:00
|
|
|
void (*deinitializer)(void*);
|
2014-10-12 07:44:45 +00:00
|
|
|
};
|
|
|
|
|
2014-11-01 10:02:10 +00:00
|
|
|
void TableInit(struct Table*, size_t initialSize, void (deinitializer(void*)));
|
2014-10-12 07:44:45 +00:00
|
|
|
void TableDeinit(struct Table*);
|
|
|
|
|
2014-11-01 10:02:10 +00:00
|
|
|
void* TableLookup(const struct Table*, uint32_t key);
|
2014-10-12 07:44:45 +00:00
|
|
|
void TableInsert(struct Table*, uint32_t key, void* value);
|
|
|
|
|
2014-11-01 10:02:10 +00:00
|
|
|
void TableRemove(struct Table*, uint32_t key);
|
|
|
|
void TableClear(struct Table*);
|
|
|
|
|
|
|
|
void TableEnumerate(const struct Table*, void (handler(void* value, void* user)), void* user);
|
|
|
|
|
|
|
|
static inline void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*))) {
|
|
|
|
TableInit(table, initialSize, deinitializer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void HashTableDeinit(struct Table* table) {
|
|
|
|
TableDeinit(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
void* HashTableLookup(const struct Table*, const char* key);
|
|
|
|
void HashTableInsert(struct Table*, const char* key, void* value);
|
|
|
|
|
|
|
|
void HashTableRemove(struct Table*, const char* key);
|
|
|
|
void HashTableClear(struct Table*);
|
|
|
|
|
|
|
|
void HashTableEnumerate(const struct Table*, void (handler(const char* key, void* value, void* user)), void* user);
|
|
|
|
|
2014-10-12 07:44:45 +00:00
|
|
|
#endif
|