all repos — mgba @ 6f591996a8307bde8d424ab37a0db67956097187

mGBA Game Boy Advance Emulator

src/util/table.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef TABLE_H
 7#define TABLE_H
 8
 9#include "util/common.h"
10
11struct TableList;
12
13struct Table {
14	struct TableList* table;
15	size_t tableSize;
16	size_t size;
17	void (*deinitializer)(void*);
18};
19
20void TableInit(struct Table*, size_t initialSize, void (deinitializer(void*)));
21void TableDeinit(struct Table*);
22
23void* TableLookup(const struct Table*, uint32_t key);
24void TableInsert(struct Table*, uint32_t key, void* value);
25
26void TableRemove(struct Table*, uint32_t key);
27void TableClear(struct Table*);
28
29void TableEnumerate(const struct Table*, void (handler(uint32_t key, void* value, void* user)), void* user);
30size_t TableSize(const struct Table*);
31
32void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*)));
33void HashTableDeinit(struct Table* table);
34
35void* HashTableLookup(const struct Table*, const char* key);
36void HashTableInsert(struct Table*, const char* key, void* value);
37
38void HashTableRemove(struct Table*, const char* key);
39void HashTableClear(struct Table*);
40
41void HashTableEnumerate(const struct Table*, void (handler(const char* key, void* value, void* user)), void* user);
42size_t HashTableSize(const struct Table*);
43
44#endif