mirror of https://github.com/mgba-emu/mgba.git
Util: Add Table size lookup functions
This commit is contained in:
parent
6583d2d07c
commit
85f96c1e63
|
@ -121,6 +121,15 @@ void TableInsert(struct Table* table, uint32_t key, void* value) {
|
|||
++list->nEntries;
|
||||
}
|
||||
|
||||
size_t TableSize(const struct Table* table) {
|
||||
size_t e = 0;
|
||||
size_t i;
|
||||
for (i = 0; i < table->tableSize; ++i) {
|
||||
e += table->table[i].nEntries;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
void TableRemove(struct Table* table, uint32_t key) {
|
||||
struct TableList* list;
|
||||
TABLE_LOOKUP_START(TABLE_COMPARATOR, list, key) {
|
||||
|
|
|
@ -24,6 +24,7 @@ void TableInsert(struct Table*, uint32_t key, void* value);
|
|||
|
||||
void TableRemove(struct Table*, uint32_t key);
|
||||
void TableClear(struct Table*);
|
||||
size_t TableSize(const struct Table*);
|
||||
|
||||
void TableEnumerate(const struct Table*, void (handler(uint32_t key, void* value, void* user)), void* user);
|
||||
|
||||
|
@ -35,6 +36,10 @@ static inline void HashTableDeinit(struct Table* table) {
|
|||
TableDeinit(table);
|
||||
}
|
||||
|
||||
static inline size_t HashTableSize(const struct Table* table) {
|
||||
return TableSize(table);
|
||||
}
|
||||
|
||||
void* HashTableLookup(const struct Table*, const char* key);
|
||||
void HashTableInsert(struct Table*, const char* key, void* value);
|
||||
|
||||
|
|
Loading…
Reference in New Issue