all repos — mgba @ fa884d071ecaa3e05ff20b45a67bf9500dd3d6b6

mGBA Game Boy Advance Emulator

include/mgba-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 <mgba-util/common.h>
10
11CXX_GUARD_START
12
13struct TableList;
14
15struct Table {
16	struct TableList* table;
17	size_t tableSize;
18	size_t size;
19	void (*deinitializer)(void*);
20};
21
22void TableInit(struct Table*, size_t initialSize, void (deinitializer(void*)));
23void TableDeinit(struct Table*);
24
25void* TableLookup(const struct Table*, uint32_t key);
26void TableInsert(struct Table*, uint32_t key, void* value);
27
28void TableRemove(struct Table*, uint32_t key);
29void TableClear(struct Table*);
30
31void TableEnumerate(const struct Table*, void (handler(uint32_t key, void* value, void* user)), void* user);
32size_t TableSize(const struct Table*);
33
34void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*)));
35void HashTableDeinit(struct Table* table);
36
37void* HashTableLookup(const struct Table*, const char* key);
38void HashTableInsert(struct Table*, const char* key, void* value);
39
40void HashTableRemove(struct Table*, const char* key);
41void HashTableClear(struct Table*);
42
43void HashTableEnumerate(const struct Table*, void (handler(const char* key, void* value, void* user)), void* user);
44size_t HashTableSize(const struct Table*);
45
46CXX_GUARD_END
47
48#endif