2014-12-03 08:39:06 +00:00
|
|
|
/* Copyright (c) 2013-2014 Jeffrey Pfau
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2014-10-12 07:44:45 +00:00
|
|
|
#ifndef TABLE_H
|
|
|
|
#define TABLE_H
|
|
|
|
|
|
|
|
#include "util/common.h"
|
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_START
|
|
|
|
|
2014-10-12 07:44:45 +00:00
|
|
|
struct TableList;
|
|
|
|
|
|
|
|
struct Table {
|
|
|
|
struct TableList* table;
|
|
|
|
size_t tableSize;
|
2016-11-01 06:45:14 +00:00
|
|
|
size_t size;
|
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*);
|
|
|
|
|
2014-12-14 08:41:03 +00:00
|
|
|
void TableEnumerate(const struct Table*, void (handler(uint32_t key, void* value, void* user)), void* user);
|
2016-11-01 06:45:14 +00:00
|
|
|
size_t TableSize(const struct Table*);
|
2014-11-01 10:02:10 +00:00
|
|
|
|
2016-10-11 20:13:44 +00:00
|
|
|
void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*)));
|
|
|
|
void HashTableDeinit(struct Table* table);
|
2014-11-01 10:02:10 +00:00
|
|
|
|
|
|
|
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);
|
2016-11-01 06:45:14 +00:00
|
|
|
size_t HashTableSize(const struct Table*);
|
2014-11-01 10:02:10 +00:00
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_END
|
|
|
|
|
2014-10-12 07:44:45 +00:00
|
|
|
#endif
|